123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584 |
- <script>
- const {
- updateManager
- } = require('./common/config.js');
- import {
- newsClassify,
- getInformationFindPage
- } from "@/api/government.js";
- export default {
- globalData: {
- statusBarHeight: 0, // 状态烂高度
- //全局配置参数
- barHeight: 0,
- screenWidth: 0,
- screenHeight: 0,
- windowHeight: 0,
- viewHeight: 0,
- openPay: true,
- navHeight: 44,
- nav_status_Height: 44,
- test: ''
- },
- onLaunch: function(options) {
- uni.preloadPage({
- url: "/pages/government/discovery",
- success: (e) => {
- console.log(e)
- },
- fail: (e) => {
- console.log(e)
- },
- });
- // this.preloadPage();
-
- this.loadExecution()
- // setTimeout(() => {
- // push.navigator.closeSplashscreen();
- // },5000)
- // push.screen.lockOrientation("/")
- // 监听事件 打开靓码页面
- uni.onTabBarMidButtonTap(() => {
- uni.navigateTo({
- url: '/pages/government/beautiful-code',
- fail: err => {
- console.log('onTabBarMidButtonTap = ', err)
- }
- });
- })
- let that = this;
- // #ifdef APP-PLUS
- plus.screen.lockOrientation('portrait-primary'); //竖屏正方向锁定
- updateManager();
- //#endif
- // #ifndef APP-PLUS
- // 是否开启支付
- // that.$http.get('/saleconfig/openPayment').then(res => {
- // if (res && res.code == 200) {
- // that.globalData.openPay = res.openPayment;
- // }
- // });
- //#endif
- if (options.query.code) {
- uni.setStorageSync('code', options.query.code);
- }
- // #ifdef APP-PLUS
- // App平台检测升级,服务端代码是通过uniCloud的云函数实现的,详情可参考:https://ext.dcloud.net.cn/plugin?id=2226
- // #endif
- //获取设备顶部窗口的高度(不同设备窗口高度不一样,根据这个来设置自定义导航栏的高度)
- uni.getSystemInfo({
- success: (res) => {
- this.globalData.barHeight = res.statusBarHeight;
- this.globalData.screenWidth = res.screenWidth;
- this.globalData.screenHeight = res.screenHeight;
- this.globalData.viewHeight = res.windowHeight;
- this.globalData.statusBarHeight = res.statusBarHeight || 0;
- this.globalData.nav_status_Height = res.statusBarHeight + this.globalData.navHeight
- },
- });
- //应用通知(消息推送)
- // uniPush1.getPushClientId()
- // #ifdef APP-PLUS
- // plus.push.getClientInfoAsync((info) => {
- // let cid = info["clientid"];
- // uni.setStorageSync('cid', cid)
- // // this.cid = cid
- // console.log(cid)
- // });
- // // #endif
- // that.getPush()
- /**
- * 校验session_key是否失效
- * 如果失效,则清空登录态,当需要登录的时候,从login.wxml重新登录
- */
- // uni.checkSession({
- // success() {
- // // sessionKey有效没有过期
- // console.log("checkSession success");
- // },
- // fail() {
- // // sessionKey已经失效,过期
- // console.log("checkSession fail");
- // // 清空登录所有相关信息
- // // clearLoginStatus();
- // },
- // });
- },
- onShow: function(e) {
- // #ifdef APP-PLUS
- setTimeout(() => {
- var args = plus.runtime.arguments;
- if (args) {
- // let obj=this.getQueryParams(args);
- // if(obj.orderNo){
- // this.getUrlType(obj.orderNo)
- // }
- try {
- let res = args.split('&');
- let pageType = res[1].split('=')[1];
- let type = res[2].split('=')[1];
- let id = res[3].split('=')[1];
- let shareId = res[4].split('=')[1];
- let teamId = res[5].split('=')[1];
- // 普通商品
- if (pageType == 1 && type == 1) {
- uni.navigateTo({
- url: '/pages/product/goods/goods?id=' + id + '&shareId=' + shareId,
- });
- }
- //积分商品
- if (pageType == 1 && type == 5) {
- uni.navigateTo({
- url: '/pages/product/goods/IntegralGood?id=' + id + '&shareId=' +
- shareId,
- });
- }
- //服务商品
- if (pageType == 1 && type == 4) {
- uni.navigateTo({
- url: '/pages/product/goods?id=' + id + '&shareId=' + shareId,
- });
- }
- //秒杀商品
- if (pageType == 1 && type == 2) {
- uni.navigateTo({
- url: '/pages/product/goods?id=' + id + '&shareId=' + shareId,
- });
- }
- //团购商品
- if (pageType == 1 && type == 3) {
- console.log('555555555');
- uni.navigateTo({
- url: '/pages/product/goods?id=' + id + '&shareId=' + shareId +
- '&teamId=' +
- teamId,
- });
- }
- //文章
- if (pageType == 2) {
- console.log('6666666');
- uni.navigateTo({
- url: '/pages/research/recommend/details?id=' + id + '&shareId=' +
- shareId,
- });
- }
- // 作品
- if (pageType == 3) {
- console.log('777777777777');
- uni.navigateTo({
- url: '/pages/research/business/article?id=' + id + '&shareId=' +
- shareId,
- });
- }
- if (pageType == 4) {
- uni.navigateTo({
- url: '/pages/login/index',
- });
- }
- } catch (e) {
- //TODO handle the exception
- }
- }
- }, 10);
- // #endif
- },
- methods: {
- // preloadPage() {
- // newsClassify({
- // informationChannel: this.$keys.information_discover
- // }).then(res => {
- // const data = res.data || [];
- // getInformationFindPage({
- // pageNum: 1,
- // pageSize: 10,
- // informationTypeId: data[0].informationTypeId
- // }).then(res => {
- // uni.setStorageSync('discoveryPage', res);
- // })
- // })
- // },
- loadExecution() {
- /**
- * 获取本地存储中launchFlag的值
- * 若存在,说明不是首次启动,直接进入首页;
- * 若不存在,说明是首次启动,进入引导页;
- */
- // push.navigator.closeSplashscreen();
- // const value = uni.getStorageSync('launchFlag');
- // console.log('value = ' , value)
- // setTimeout(() => {
- // if (value == true) {
- // uni.switchTab({
- // url: '/pages/home',
- // success: res => {
- // push.navigator.closeSplashscreen();
- // },
- // fail: () => {
- // push.navigator.closeSplashscreen();
- // }
- // });
- // } else {
- // push.navigator.closeSplashscreen();
- // }
- // })
- try {
- const value = uni.getStorageSync('launchFlag');
- // console.log('value = ' , value)
- if (value) {
- if (value == true) {
- uni.redirectTo({
- url: '/pages/index/secondaryGuide'
- });
- } else {
- uni.redirectTo({
- url: '/pages/index/guide'
- });
- }
- } else {
- uni.setStorage({
- key: 'launchFlag',
- data: true,
- success: function() {
- console.log('存储launchFlag');
- }
- });
- uni.redirectTo({
- url: '/pages/index/guide'
- });
- }
- } catch (e) {
- // error
- uni.setStorage({
- key: 'launchFlag',
- data: true,
- success: function() {
- console.log('error时存储launchFlag');
- }
- });
- uni.redirectTo({
- url: '/pages/index/guide',
- });
- }
- },
- watchRouter(e) {
- console.log('路由进行跳转', JSON.stringify(e.url));
- },
- getUrlType(orderNo) {
- this.$yghttp.post('/sand/order/getRedirectMode', {
- orderNo: orderNo
- }).then(res => {
- console.log(res)
- if (res.data.jumpType == 1) {
- uni.redirectTo({
- url: res.data.path
- });
- } else if (res.data.jumpType == 2) {
- uni.redirectTo({
- url: "/pages/web-view/Apps?path=" + res.data.path + '&title=唯品会'
- })
- }
- })
- },
- getQueryParams(e) {
- const paramsString = e; // 将查询字符串转换为字符串
- const paramsArray = paramsString.split('&'); // 将字符串按 & 分割成数组
- // 遍历数组,将每个参数存储到对象中
- const paramsObj = {};
- for (let i = 0; i < paramsArray.length; i++) {
- const [key, value] = paramsArray[i].split('=');
- paramsObj[decodeURIComponent(key)] = decodeURIComponent(value);
- }
- return paramsObj
- },
- //跳转
- jump(item, obj) {
- let that = this;
- if (item.type == 0) {
- let activityType = obj.activity_type;
- if (activityType == 1) {
- uni.navigateTo({
- url: '/pages/research/nearby/timeLimit',
- });
- }
- if (activityType == 2) {
- uni.navigateTo({
- url: '/pages/research/homepage/groupList',
- });
- }
- }
- //支付消息
- if (item.type == 1) {
- let goodsType = obj.goods_type;
- if (goodsType == 0) {
- let id = obj.order_id;
- uni.navigateTo({
- url: `/pages/order/orderList/orderDetails?id=${id}&status=pay`,
- });
- //普通商品完成
- }
- if (goodsType == 1) {
- let id = obj.order_id;
- uni.navigateTo({
- url: `/pages/order/orderList/serviceOrderDetail?id=${id}&status=pay`,
- });
- //服务详情完成
- }
- if (goodsType == 2) {
- let id = obj.order_id;
- if (obj.activity_type == 2) {
- uni.navigateTo({
- url: '/pages/order/gbOrder/gbOrderDetails?id=' +
- id +
- '&status=pay' +
- '&groupId=' +
- obj.goods[0].team_member_id,
- });
- }
- //跳转秒杀详情地址还没写上去
- else if (obj.activity_type == 1) {
- uni.navigateTo({
- // url:"/pages/product/goods/seckillGoods?id="+obj.goods[0].goods_id
- url: `/pages/order/orderList/orderDetails?id=${id}&status=pay`,
- });
- }
- }
- //积分商品
- if (goodsType == 3) {
- let id = obj.order_id;
- uni.navigateTo({
- url: `/pages/order/orderList/orderDetails?id=${id}&status=pay`,
- });
- //完成
- }
- // if (goodsType == 4) {
- // uni.navigateTo({
- // url: "/pages/user/wallet/transactionDetail"
- // })
- // }
- }
- //物流消息
- if (item.type == 2) {
- let logisticsStatus = obj.logistics_status;
- if (logisticsStatus == 0) {
- let id = obj.order_id;
- uni.navigateTo({
- url: `/pages/order/orderList/orderDetails?id=${id}&status=pay`,
- });
- }
- if (logisticsStatus == 1) {
- let id = obj.order_id;
- uni.navigateTo({
- url: `/pages/order/orderList/orderDetails?id=${id}&status=pay`,
- });
- }
- }
- //售后消息
- if (item.type == 3) {
- let id = obj.rights_order_id;
- console.log(id);
- that.$http.get(`/rights/info/${id}`).then((res) => {
- if (res && res.code == 200) {
- let shopid = res.data.shop_id;
- let rightsType = res.data.rights_type;
- let rightsRefundStatus = res.data.rights_operate_status;
- uni.navigateTo({
- url: '/pages/order/orderList/orderblackDetails?id=' +
- id +
- '&shopid=' +
- shopid +
- '&type=' +
- rightsType +
- '&status=' +
- rightsRefundStatus,
- });
- } else {
- uni.showToast({
- title: '无此订单',
- icon: 'none',
- duration: 2000,
- });
- }
- });
- //先全部跳售后详情
- }
- // 互动消息
- if (item.type == 4) {
- let id = item.user_id;
- let personalType = obj.type;
- // if (personalType == 0 || personalType == 2) {
- // let id = obj.model_id
- // uni.navigateTo({
- // url: "/pages/research/recommend/details?id=" + id
- // })
- // } else if (personalType == 1) {
- // let id = item.user_id
- // uni.navigateTo({
- // url: "/pages/research/community/homepage?user_id=" + id
- // })
- // } else if (personalType == 3) {
- // let id = obj.model_id
- // uni.navigateTo({
- // url: "/pages/research/setup/toExamine?id=" + id
- // })
- // } else if (personalType == 4) {
- // let id = obj.model_id
- // uni.navigateTo({
- // url: "/pages/research/setup/toBusiness?id=" + id
- // })
- // }
- if (personalType == 4) {
- // let id = obj.model_id
- uni.navigateTo({
- url: '/pages/user/merchant/audit',
- });
- } else if (personalType == 5) {
- uni.navigateTo({
- url: '/pages/workbench/shop/audit',
- });
- }
- }
- // 系统消息
- if (item.type == 5) {
- if (obj.type == 0) {
- uni.navigateTo({
- url: `/pages/user/regional-agency/index`,
- });
- }
- }
- },
- getPush() {
- // #ifdef APP-PLUS
- plus.push.setAutoNotification(true); //设置通知栏显示通知必须设置
- //从系统消息中心点击消息启动应用事件
- let that = this;
- let platform = uni.getSystemInfoSync().platform;
- plus.push.addEventListener(
- 'click',
- (data) => {
- // JSON.parse(data.payload)
- // uni.setClipboardData({
- // data: data,
- // success: function(res) {
- // uni.showToast({
- // title: '复制成功',
- // });
- // }
- // });
- // uni.showModal({
- // title: '苹果离线提示11' + Object.prototype.toString.call(data) + 'type::'+data.type,
- // content: JSON.stringify(data),
- // success: function(res) {
- // if (res.confirm) {
- // console.log('用户点击确定');
- // } else if (res.cancel) {
- // console.log('用户点击取消');
- // }
- // }
- // });
- if (platform == 'ios' && data.type == 'click') {
- //苹果离线点击事件
- let obj = data.payload.payload.message_body;
- let item = data.payload.payload;
- that.jump(item, obj);
- }
- if (platform == 'ios') {
- //苹果在线点击事件
- let item = JSON.parse(data.payload);
- let obj = item.message_body;
- that.jump(item, obj);
- }
- if (platform == 'android') {
- //安卓在线点击事件
- let item = data.payload;
- let obj = item.message_body;
- that.jump(item, obj);
- }
- },
- false
- );
- //应用从推送服务器接收到推送消息事件
- plus.push.addEventListener(
- 'receive',
- (res) => {
- if (platform == 'android') {
- //安卓在线推送
- // item = res.payload
- var options = {
- cover: false,
- title: res.title,
- };
- plus.push.createMessage(res.content, res.payload, options);
- // uni.showModal({
- // title: '安卓在线提示11' + Object.prototype.toString.call(res.payload),
- // content: JSON.stringify(res.payload),
- // success: function(r) {
- // if (r.confirm) {
- // console.log('用户点击确定');
- // } else if (r.cancel) {
- // console.log('用户点击取消');
- // }
- // }
- // });
- } else {
- //苹果在线推送事件
- if (res.aps == null || res.type == 'receive') {
- var options = {
- cover: false,
- title: res.title,
- };
- plus.push.createMessage(res.content, JSON.stringify(res.payload), options);
- }
- }
- },
- false
- );
- // #endif
- },
- },
- onHide: function() {
- console.log('App Hide');
- },
- };
- </script>
- <style lang="scss">
- //全局引入政务模块样式
- @import './common/style/zw.scss';
- //全局引入骨架屏幕样式
- @import './common/style/skeleton.scss';
- //全局引入u-view ui框架样式
- @import 'uview-ui/index.scss';
- /* #ifndef APP-PLUS-NVUE */
- @import '@/common/style/common.scss';
- /* uni.css - 通用组件、模板样式库,可以当作一套ui库应用 */
- @import './common/style/uni.css';
- /* #endif */
- uni-radio .uni-radio-input .uni-radio-input-checked {
- background: #ff0000 !important;
- }
- // 骨架屏遮罩
- .u-skeleton-box {
- position: relative;
- .u-skeleton-shade {
- width: 100% !important;
- z-index: 1 !important;
- top: 0 !important;
- left: 0 !important;
- }
- }
- </style>
|