1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import Vue from 'vue'
import App from './App'
import { php } from './common/host.js';
Vue.config.productionTip = false
// 加入购物车
function addCart(spec_id, quantity, isLogin) {
if(!isLogin) {
uni.showToast({
title: '请先登录',
duration: 2000,
icon: 'none'
});
setTimeout(() => {
window.location.href = php+'app=member&act=login';
}, 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'
});
}
})
}
Vue.prototype.$addCart = addCart;
Vue.prototype.$noGoodsImg = 'https://dbc-static.oss-cn-beijing.aliyuncs.com/credit/shangpinmorentu%402x.png';
Vue.prototype.$defaultPortrait = 'https://dbc-static.oss-cn-beijing.aliyuncs.com/credit/default_user_portrait.gif';
Vue.prototype.$defaultClassImg = 'https://dbc-static.oss-cn-beijing.aliyuncs.com/credit_shop/20190520/img/5ce2636edf912.png';
App.mpType = 'app'
const app = new Vue({
...App
})
app.$mount()