import Vue from 'vue'; import App from './App'; import contactButton from "@/components/contact-button/index"; import cart from '@/components/shopping-cart/index'; import updateUserinfo from '@/components/update-userinfo/index'; import privacy from '@/components/privacy/index'; import simplePhone from "@/components/simple-phone/index"; import wxShare from './components/wx-share/share.vue' import {wxAuthorize} from './utils/wx-gz-authorize.js' import 'uni-js-bridge' Vue.prototype.wxOauth=wxAuthorize; Vue.config.productionTip = false; Vue.component("contact-button", contactButton); Vue.component("cart", cart); Vue.component("update-userinfo", updateUserinfo); Vue.component("privacy", privacy); Vue.component("simple-phone", simplePhone); Vue.component("wx-share", wxShare); import action from "@/action_sdk/actionTemplete.js" Vue.mixin(action) import h5Templete from "@/utils/h5Templete.js" Vue.mixin(h5Templete) Vue.mixin({ methods: { setData: function(obj, callback) { let that = this; const handleData = (tepData, tepKey, afterKey) => { tepKey = tepKey.split('.'); tepKey.forEach(item => { if (tepData[item] === null || tepData[item] === undefined) { let reg = /^[0-9]+$/; tepData[item] = reg.test(afterKey) ? [] : {}; tepData = tepData[item]; } else { tepData = tepData[item]; } }); return tepData; }; const isFn = function(value) { return typeof value == 'function' || false; }; Object.keys(obj).forEach(function(key) { let val = obj[key]; key = key.replace(/\]/g, '').replace(/\[/g, '.'); let front, after; let index_after = key.lastIndexOf('.'); if (index_after != -1) { after = key.slice(index_after + 1); front = handleData(that, key.slice(0, index_after), after); } else { after = key; front = that; } if (front.$data && front.$data[after] === undefined) { Object.defineProperty(front, after, { get() { return front.$data[after]; }, set(newValue) { front.$data[after] = newValue; that.$forceUpdate(); }, enumerable: true, configurable: true }); front[after] = val; } else { that.$set(front, after, val); } }); // this.$forceUpdate(); isFn(callback) && this.$nextTick(callback); } } }); App.mpType = 'app'; const app = new Vue({ ...App }); app.$mount();