import Vue from 'vue' import App from './App' import { php } from './common/host.js'; Vue.config.productionTip = false // 加入购物车 let isLogin = 0; function addCart(spec_id, quantity) { if(!isLogin) { uni.showToast({ title: '请先登录', duration: 2000, icon: 'none' }); setTimeout(() => { window.location.href = php; }, 2000); return } uni.request({ url: '/uni/api//credit_goods/add_cart', method: 'post', dataType: 'json', data: { spec_id: spec_id, quantity: quantity }, success: (res) => { let msg = ''; if(res.data.code == 0) { msg = '已加入购物车' } else { msg = res.data.messages } uni.showToast({ title: msg, duration: 2000, icon: 'none' }); } }) } (function() { uni.request({ url: '/uni/api/application/is_login', type:'get', success: (res) => { Vue.prototype.$isLogin = res.data.data; isLogin = res.data.data; } }); })() Vue.prototype.$addCart = addCart; Vue.prototype.$noGoodsImg = '/static/common/shangpinmorentu@2x.png'; App.mpType = 'app' const app = new Vue({ ...App }) app.$mount()