/* * @Author: your name * @Date: 2021-01-25 11:32:04 * @LastEditTime: 2021-04-02 16:29:26 * @LastEditors: Please set LastEditors * @Description: In User Settings Edit * @FilePath: \rebatedine-mini\src\main.js */ import Vue from 'vue' import App from './App' import store from './store/index' // import uView from 'uview-ui' import dayjs from './utils/dayjs.min.js' import dealImgUrl from '@/utils/dealImgUrl' import networkError from '@/components/networkError' import * as commonApi from '@/api/commonApi' Vue.config.productionTip = false App.mpType = 'app' Vue.prototype.$store = store Vue.prototype.$dayjs = dayjs // Vue.use(uView) Vue.filter('imgFilter', (fileItem, type) => { return dealImgUrl(fileItem, type) }) Vue.filter('imgListFilter', (fileList, type) => { fileList.forEach(item => { item.url = dealImgUrl(item, type) }) return fileList }) Vue.mixin({ onLoad (options) { console.log(111) options = this.dealOptions(options) const inviteId = options.INVITE_ID if (inviteId && !this.$store.state.INVITE_ID) { this.$store.commit('saveInviteId', inviteId) } // #ifdef H5 const url = window.location.href.substring( 0, window.location.href.indexOf('#') ) console.log(wx) console.log(wx.agentConfig) console.log(jWeixin) commonApi.signUrl({ url }).then(({ code, data }) => { if (code === 200) { jWeixin.agentConfig({ corpid: data.corpid, // 必填,企业微信的corpid,必须与当前登录的企业一致 agentid: data.agentid, // 必填,企业微信的应用id (e.g. 1000247) timestamp: data.timestamp, // 必填,生成签名的时间戳 nonceStr: data.noncestr, // 必填,生成签名的随机串 signature: data.sign, // 必填,签名,见附录-JS-SDK使用权限签名算法 jsApiList: data.jsApiList, // 必填,传入需要使用的接口名称 success: function (res) { // 回调 console.log('success') }, fail: function (res) { if (res.errMsg.indexOf('function not exist') > -1) { alert('版本过低请升级') } else { console.log(res.errMsg) } } }) } }) // #endif }, methods: { dealJumpInfo (banner) { switch (banner.jump_type * 1) { case 1: uni.navigateTo({ url: `/pagesSub/other/webView?url=${banner.jump_content}` }) break case 2: this.$store.dispatch('toOtherApplte', banner.jump_content) break case 3: uni.navigateTo({ url: `/pagesSub/activity/activityDetail?id=${banner.jump_content}` }) break case 4: console.log('jump_content', banner.jump_content) this.$store.commit('changeCateId', banner.jump_content) uni.switchTab({ url: '/pages/classification' }) break case 5: this.$store.commit('changeCateId', banner.jump_content) uni.navigateTo({ url: '/pagesSub/other/noviceStrategy' }) break default: } }, dealOptions (options) { let option = options if (Object.prototype.hasOwnProperty.call(option, 'scene')) { const str = decodeURIComponent(option.scene).split('&') const json = {} str.forEach(item => { const index = item.indexOf('=') json[item.slice(0, index)] = item.slice(index + 1) }) option = json } for (const key in option) { option[key.toUpperCase()] = option[key] } return option } }, onShareAppMessage (res) { const title = '请你趣吃霸王餐' let url = '/pages/index' if (this.$store.userInfo) { url += '?invite_id=' + this.$store.userInfo.id } return { title: title, path: url } }, onShareTimeline (res) { const title = '请你趣吃霸王餐' let url = '/pages/index' if (this.$store.userInfo) { url += '?invite_id=' + this.$store.userInfo.id } return { title: title, path: url } } }) Vue.component('network-error', networkError) const app = new Vue({ ...App }) app.$mount()