|
|
@ -13,6 +13,7 @@ Page({ |
|
|
|
winHeight: 0, |
|
|
|
currentTab: 0, //tab切换
|
|
|
|
productId: 0, |
|
|
|
attributeId: 0, |
|
|
|
itemData: {}, |
|
|
|
wsc: 'bxs', |
|
|
|
sc: 'bxs', |
|
|
@ -44,29 +45,29 @@ Page({ |
|
|
|
duration: 1500, |
|
|
|
}); |
|
|
|
|
|
|
|
app.request.wxRequest({ |
|
|
|
url: '&action=getcode&m=product_share', |
|
|
|
data: { |
|
|
|
product_img_path: that.data.itemData.photo_d, |
|
|
|
product_title: that.data.title, |
|
|
|
price: that.data.itemData.price_yh, |
|
|
|
yprice: that.data.itemData.price, |
|
|
|
scene: 'productId=' + that.data.productId + '&referee_openid=' + app.globalData.userInfo.user_id, |
|
|
|
path: 'pages/product/detail', |
|
|
|
id: app.globalData.userInfo.user_id, |
|
|
|
pid: that.data.productId, |
|
|
|
head: app.globalData.userInfo.avatarUrl, |
|
|
|
name: app.globalData.userInfo.nickName, |
|
|
|
type: 3 |
|
|
|
}, |
|
|
|
method: 'post', |
|
|
|
success: function (res) { |
|
|
|
that.setData({ |
|
|
|
maskHidden: true, |
|
|
|
imagePath: res.url, |
|
|
|
}); |
|
|
|
} |
|
|
|
}) |
|
|
|
// app.request.wxRequest({
|
|
|
|
// url: '&action=getcode&m=product_share',
|
|
|
|
// data: {
|
|
|
|
// product_img_path: that.data.itemData.photo_d,
|
|
|
|
// product_title: that.data.title,
|
|
|
|
// price: that.data.itemData.price_yh,
|
|
|
|
// yprice: that.data.itemData.price,
|
|
|
|
// scene: 'productId=' + that.data.productId + '&referee_openid=' + app.globalData.userInfo.user_id,
|
|
|
|
// path: 'pages/product/detail',
|
|
|
|
// id: app.globalData.userInfo.user_id,
|
|
|
|
// pid: that.data.productId,
|
|
|
|
// head: app.globalData.userInfo.avatarUrl,
|
|
|
|
// name: app.globalData.userInfo.nickName,
|
|
|
|
// type: 3
|
|
|
|
// },
|
|
|
|
// method: 'post',
|
|
|
|
// success: function (res) {
|
|
|
|
// that.setData({
|
|
|
|
// maskHidden: true,
|
|
|
|
// imagePath: res.url,
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
// })
|
|
|
|
|
|
|
|
var animation = wx.createAnimation({ |
|
|
|
duration: 200, |
|
|
@ -127,23 +128,22 @@ Page({ |
|
|
|
// 属性选择
|
|
|
|
onShow: function () { |
|
|
|
var that = this; |
|
|
|
|
|
|
|
that.getUserId(); |
|
|
|
}, |
|
|
|
//接受formid
|
|
|
|
getUserformid: function (e) { |
|
|
|
var formid = e.detail.formId; |
|
|
|
this.sendFormid(formid, 'kt1'); |
|
|
|
this.setModalStatus(e); |
|
|
|
}, |
|
|
|
//接受formid
|
|
|
|
sendFormid: function (fromid, page) { |
|
|
|
var that = this |
|
|
|
app.request.wxRequest({ |
|
|
|
url: '&action=draw&m=getFormid', |
|
|
|
data: { from_id: fromid, userid: app.globalData.userInfo.openid, page: page }, |
|
|
|
method: 'post', |
|
|
|
success: function () { |
|
|
|
|
|
|
|
getUserId() { |
|
|
|
WXAPI.userIndex({ |
|
|
|
accessId: app.globalData.accessId, |
|
|
|
storeId: 239, |
|
|
|
storeType: 1, |
|
|
|
mobile:'', |
|
|
|
}).then(res => { |
|
|
|
if (res.code == 200) { |
|
|
|
var data = res.data; |
|
|
|
if (!data.data) { |
|
|
|
wx.removeStorageSync('accessId') |
|
|
|
wx.removeStorageSync('isLogin'); |
|
|
|
wx.removeStorageSync('userInfo'); |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
@ -152,7 +152,7 @@ Page({ |
|
|
|
var that = this; |
|
|
|
var choujiangid = that.data.choujiangid; |
|
|
|
var openid = app.globalData.userInfo.openid; |
|
|
|
console.log(app.globalData.userInfo, 'openid') |
|
|
|
// console.log(app.globalData.userInfo, 'openid')
|
|
|
|
// if (openid) {
|
|
|
|
var bgcolor = app.d.bgcolor; |
|
|
|
// wx.setNavigationBarColor({
|
|
|
@ -521,62 +521,45 @@ Page({ |
|
|
|
/* 点击确定 */ |
|
|
|
submit: function (e) { |
|
|
|
var that = this; |
|
|
|
var sizeid = that.data.sizeid; |
|
|
|
|
|
|
|
if (sizeid == '' || sizeid.length < 1) { |
|
|
|
wx.showToast({ |
|
|
|
title: '请完善属性', |
|
|
|
icon: 'loading', |
|
|
|
duration: 1000 |
|
|
|
}) |
|
|
|
var type = e.currentTarget.dataset.type; |
|
|
|
if (type == 'buynow') { |
|
|
|
that.buyNow(e) |
|
|
|
} else { |
|
|
|
var type = e.target.dataset.type; |
|
|
|
var sizeid = sizeid; |
|
|
|
that.addShopCart(e, sizeid) |
|
|
|
that.addShopCart(e) |
|
|
|
} |
|
|
|
}, |
|
|
|
//购物车直接结算
|
|
|
|
Settlement: function () { |
|
|
|
settlement: function () { |
|
|
|
console.log('-Settlement-') |
|
|
|
wx.switchTab({ |
|
|
|
url: '../cart/cart' |
|
|
|
}) |
|
|
|
return; |
|
|
|
}, |
|
|
|
addShopCart: function (e, sizeid) { |
|
|
|
//加入购物车
|
|
|
|
addShopCart: function (e) { |
|
|
|
//添加到购物车
|
|
|
|
var that = this; |
|
|
|
var pro_type = e.target.dataset.type; |
|
|
|
var ptype = e.currentTarget.dataset.type; |
|
|
|
// console.log(ptype, '--jnkmjkl')
|
|
|
|
WXAPI.productAddCart({ |
|
|
|
uid: app.globalData.userInfo.openid, |
|
|
|
pid: that.data.productId, |
|
|
|
accessId: app.globalData.accessId, |
|
|
|
storeId: 239, |
|
|
|
storeType: 1, |
|
|
|
pro_id: that.data.productId, |
|
|
|
attribute_id: that.data.sizeid, |
|
|
|
num: that.data.buynum, |
|
|
|
sizeid: sizeid, |
|
|
|
pro_type: pro_type, |
|
|
|
type: 'addcart', |
|
|
|
}).then(res => { |
|
|
|
if (res.code == 200) { |
|
|
|
//设置购物车刷新
|
|
|
|
app.d.purchase = 1; |
|
|
|
var data = res.data; |
|
|
|
var ptype = e.currentTarget.dataset.type; |
|
|
|
if (ptype == 'buynow') { |
|
|
|
wx.redirectTo({ |
|
|
|
url: '../order/pay?cartId=' + data.cart_id + '&pid=' + that.data.productId + '&num=' + that.data.buynum + '&type=1', |
|
|
|
}); |
|
|
|
return; |
|
|
|
} else { |
|
|
|
wx.showToast({ |
|
|
|
title: '加入购物车成功', |
|
|
|
icon: 'success', |
|
|
|
duration: 2000 |
|
|
|
}); |
|
|
|
// util.getUesrBgplus(that, app, true)
|
|
|
|
that.setData({ |
|
|
|
showModalStatus: false |
|
|
|
}); |
|
|
|
} |
|
|
|
wx.showToast({ |
|
|
|
title: '加入购物车成功', |
|
|
|
icon: 'success', |
|
|
|
duration: 2000 |
|
|
|
}); |
|
|
|
that.setData({ |
|
|
|
showModalStatus: false |
|
|
|
}); |
|
|
|
} else { |
|
|
|
wx.showToast({ |
|
|
|
icon: 'loading', |
|
|
@ -586,6 +569,26 @@ Page({ |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
//立即购买
|
|
|
|
buyNow: function (e) { |
|
|
|
var isLogin = wx.getStorageSync('isLogin') |
|
|
|
if (!isLogin) { |
|
|
|
wx.navigateTo({ |
|
|
|
url: '/pages/login/login' |
|
|
|
}) |
|
|
|
} |
|
|
|
//添加到购物车
|
|
|
|
var that = this; |
|
|
|
var productArr = [] |
|
|
|
productArr.push({pid: that.data.productId}) |
|
|
|
productArr.push({cid: that.data.sizeid}) |
|
|
|
productArr.push({num: that.data.buynum}) |
|
|
|
// productArr.push({})
|
|
|
|
let jsonstr = JSON.stringify(productArr) |
|
|
|
wx.navigateTo({ |
|
|
|
url: '../order/pay?product=' + jsonstr + '&cart_id=' + that.data.cart_id, |
|
|
|
}); |
|
|
|
}, |
|
|
|
bindChange: function (e) {//滑动切换tab
|
|
|
|
var that = this; |
|
|
|
that.setData({ currentTab: e.detail.current }); |
|
|
@ -617,7 +620,6 @@ Page({ |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
onShareAppMessage: function (res) { |
|
|
|
var that = this; |
|
|
|
var id = that.data.productId; |
|
|
@ -739,23 +741,17 @@ Page({ |
|
|
|
preventTouchMove: function (e) { |
|
|
|
|
|
|
|
}, |
|
|
|
add_fromid: function (e) { |
|
|
|
var isLogin = wx.getStorageSync('isLogin') |
|
|
|
if (!isLogin) { |
|
|
|
wx.navigateTo({ |
|
|
|
url: '/pages/login/login' |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
showAttribute: function (e) { |
|
|
|
// console.log(e)
|
|
|
|
var that = this; |
|
|
|
var formId = e.detail.formId; |
|
|
|
var animation = wx.createAnimation({ |
|
|
|
duration: 200, |
|
|
|
timingFunction: "linear", |
|
|
|
delay: 0 |
|
|
|
}); |
|
|
|
//定义点击的类型
|
|
|
|
var type = e.detail.target.dataset.type ? e.detail.target.dataset.type : false; |
|
|
|
|
|
|
|
var type = e.currentTarget.dataset.type ? e.currentTarget.dataset.type : false; |
|
|
|
//控制两种不同显示方式
|
|
|
|
if (type) { |
|
|
|
this.setData({ |
|
|
@ -773,7 +769,7 @@ Page({ |
|
|
|
paytype: type, |
|
|
|
animationData: animation.export() |
|
|
|
}) |
|
|
|
if (e.detail.target.dataset.status == 1) { |
|
|
|
if (e.currentTarget.dataset.status == 1) { |
|
|
|
this.setData({ |
|
|
|
showModalStatus: true |
|
|
|
}); |
|
|
@ -783,24 +779,12 @@ Page({ |
|
|
|
this.setData({ |
|
|
|
animationData: animation |
|
|
|
}) |
|
|
|
if (e.detail.target.dataset.status == 0) { |
|
|
|
if (e.currentTarget.dataset.status == 0) { |
|
|
|
this.setData({ |
|
|
|
showModalStatus: false |
|
|
|
}); |
|
|
|
} |
|
|
|
}.bind(this), 200); |
|
|
|
if (formId != 'the formId is a mock one') { |
|
|
|
var page = 'pages/product/detail' |
|
|
|
app.request.wxRequest({ |
|
|
|
url: '&action=product&m=save_formid', |
|
|
|
data: { from_id: formId, userid: app.globalData.userInfo.openid }, |
|
|
|
method: 'post', |
|
|
|
success: function (res) { |
|
|
|
|
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
// 弹窗
|
|
|
|
set_share: function (e) { |
|
|
|