作者 刘朕

功能更新

... ... @@ -47,14 +47,16 @@ App({
// 滨海
var entrance_type = wx.getStorageSync("entrance_type");
console.log(entrance_type);
if (entrance_type == '1' || url == '/getopenid/get' || url.indexOf('address') > -1 || url.indexOf('/wb/wb')>-1) {
if (entrance_type == '1' || entrance_type == '0' || url == '/getopenid/get' || url.indexOf('/wb/wb')>-1) {
//劳保商城入口
// baseUrl = 'https://binhai.w.broing.cn/api';
baseUrl = 'http://binhai.shs.broing.cn/api'
console.log('11111111111111111')
baseUrl = 'https://binhai.w.broing.cn/api';
// baseUrl = 'http://binhai.shs.broing.cn/api'
} else if (entrance_type == '2') {
//工会商城入口
// baseUrl = 'https://binhaigh.w.broing.cn/api';
baseUrl = 'http://gonghui.shs.broing.cn/api'
console.log('@@@@@@@@@@@@@@@@@@@@@@')
baseUrl = 'https://binhaigh.w.broing.cn/api';
// baseUrl = 'http://gonghui.shs.broing.cn/api'
} else if (entrance_type == '3') {
//办公入口
baseUrl = 'https://bgcb.w.broing.cn/api';
... ...
... ... @@ -79,7 +79,7 @@ Page({
// 修改地址
editAddressFun(e) {
wx.navigateTo({
url: '/pages/address/edit_address/edit_address?id=' + e.currentTarget.dataset.id,
url: '/packageA/pages/address/edit_address/edit_address?id=' + e.currentTarget.dataset.id,
})
},
... ...
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
success: false,
fail: false,
name: '',
choudanNum: 0,
addressId: 0,
tel: '',
area: '',
address: '',
cover_type: false,
total: '',
payMent: '',
orderPayMent: '',
info: {
address: {
address: '',
area: '',
id: '',
tel: '',
name: ''
}
}
},
//加减商品数量
num_change(e) {
let that = this
let num = Number(e.currentTarget.dataset.num)
console.log(num)
let type = e.currentTarget.dataset.type
let index = e.currentTarget.dataset.index
let id = e.currentTarget.dataset.id
let check = e.currentTarget.dataset.check
let coudan = this.data.coudan || []
let coudan_arr = this.data.coudan_arr || []
let price = e.currentTarget.dataset.price;
let price2 = e.currentTarget.dataset.price2;
/**
* 页面的初始数据
*/
data: {
success: false,
fail: false,
name: '',
choudanNum:0,
addressId: 0,
tel: '',
area: '',
address: '',
cover_type: false,
total:'',
info:{
address:{
address:'',
area:'',
id:'',
tel:'',
name:''
}
}
},
//加减商品数量
num_change(e) {
let that = this
let num = Number(e.currentTarget.dataset.num)
console.log(num)
let type = e.currentTarget.dataset.type
let index = e.currentTarget.dataset.index
let id = e.currentTarget.dataset.id
let check = e.currentTarget.dataset.check
let coudan = this.data.coudan||[]
let coudan_arr = this.data.coudan_arr||[]
let price = e.currentTarget.dataset.price;
let price2 = e.currentTarget.dataset.price2;
if (type == 1) {
if(this.data.info.choudan*100<(price*100)){
wx.showToast({
title: '当前剩余积分不足,请重新挑选',
icon:'none'
})
return
}
num++
} else {
num--
if (num < 0) {
num = 0;
return
}
}
if (type == 1) {
if (this.data.info.choudan * 100 < (price * 100)) {
wx.showToast({
title: '当前剩余积分不足,请重新挑选',
icon: 'none'
})
return
}
num++
} else {
num--
if (num < 0) {
num = 0;
return
}
if (num<1) {
coudan.forEach((item, index) => {
if (item.id == id) {
coudan.splice(index, 1)
coudan_arr.splice(index, 1)
}
if (num < 1) {
coudan.forEach((item, index) => {
if (item.id == id) {
coudan.splice(index, 1)
coudan_arr.splice(index, 1)
}
})
} else {
if (type == 1 && num == 1) {
})
} else {
if(type==1&&num==1){
//选中
coudan.push({
id: id,
num: num
})
coudan_arr.push({
id: id,
num: num,
price: Number(price),
price2: Number(price2)
})
} else {
coudan.forEach((item, index) => {
if (item.id == id) {
item.num = num
coudan_arr[index].num = num
}
})
}
}
that.setData({
coudan: coudan,
coudan_arr: coudan_arr,
[`info.coudanProduct[${index}].num`]: num
// [`info.coudanProduct[${index}].check`]: check
})
this.get_choudan()
},
// 计算凑单费用
get_choudan() {
let coudan_arr = this.data.coudan_arr
let choudan_money = 0;
let num = 0
for (let obj of coudan_arr) {
console.log(obj)
console.log(obj.price2)
if (obj.price2 != null) {
console.log(111)
choudan_money = (obj.price2 * 100 * obj.num) / 100 + choudan_money
} else {
console.log(222)
choudan_money = (obj.price * 100 * obj.num) / 100 + choudan_money
coudan.push({
id: id,
num: num
})
coudan_arr.push({
id: id,
num: num,
price: Number(price),
price2:Number(price2)
})
}else{
coudan.forEach((item, index) => {
if (item.id == id) {
item.num = num
coudan_arr[index].num = num
}
num = num + obj.num
})
}
this.setData({
choudan_money: choudan_money * 100,
choudanNum: num,
'info.choudan': this.data.info.syjf - choudan_money
// choudan_money: Math.floor(choudan_money* 100) / 100
})
},
show_cover() {
let that = this
if (!that.data.cover_type) {
if (that.data.info.status == 0) {
that.setData({
fail: true
})
return
}
if (!that.data.info.address) {
wx.showToast({
title: '请添加地址',
icon: 'none',
duration: 1000
})
return
}
}
that.setData({
cover_type: !this.data.cover_type
})
},
// 去添加地址
add_address() {
wx.navigateTo({
url: '/pages/address/address',
})
},
}
that.setData({
coudan: coudan,
coudan_arr: coudan_arr,
[`info.coudanProduct[${index}].num`]: num
// [`info.coudanProduct[${index}].check`]: check
})
this.get_choudan()
},
// 计算凑单费用
get_choudan() {
let coudan_arr = this.data.coudan_arr
let choudan_money = 0;
let num = 0
for (let obj of coudan_arr) {
console.log(obj)
console.log(obj.price2)
if (obj.price2!= null) {
console.log(111)
choudan_money = (obj.price2 * 100 * obj.num) / 100 + choudan_money
} else {
console.log(222)
choudan_money = (obj.price * 100 * obj.num) / 100 + choudan_money
}
num = num+obj.num
}
//选择凑单商品
chooseGoods(e) {
// coudan 凑单商品组成的数组
// coudan_type 凑单的状态 可能废弃
let that = this
let coudan = this.data.coudan ? this.data.coudan : []
let coudan_arr = this.data.coudan_arr ? this.data.coudan_arr : []
let check = e.currentTarget.dataset.check
let num = e.currentTarget.dataset.num
let index = e.currentTarget.dataset.index
let id = e.currentTarget.dataset.id
let price = e.currentTarget.dataset.price;
let price2 = e.currentTarget.dataset.price2;
if (check) {
check = 0
coudan.forEach((item, index) => {
if (item.id == id) {
coudan.splice(index, 1)
coudan_arr.splice(index, 1)
}
})
} else {
check = 1
//选中
coudan.push({
id: id,
num: num
})
coudan_arr.push({
id: id,
num: num,
price: Number(price),
price2: Number(price2)
})
}
this.setData({
choudan_money: choudan_money*100,
choudanNum:num,
'info.choudan': this.data.info.syjf - choudan_money
// choudan_money: Math.floor(choudan_money* 100) / 100
})
},
show_cover() {
let that = this
if (!that.data.cover_type) {
if (that.data.info.status == 0) {
that.setData({
coudan: coudan,
coudan_arr: coudan_arr,
[`info.coudanProduct[${index}].check`]: check
})
that.get_choudan()
},
//获取页面信息
get_info(type, info, id) {
let that = this
let url = type == 4 ? app.interface.prev_pay : app.interface.now_prev_pay
let params = {
info: info
}
app.post(url, params).then((res) => {
console.log('99999', res, Number(res.msg.total))
res.msg.syjf = res.msg.choudan - res.msg.yunfei
let a = (res.msg.choudan - res.msg.yunfei).toFixed(2)
if (a < 0) {
a = 0
}
res.msg.choudan = a
res.msg.total = Number(res.msg.total * 100)
res.msg.yunfei = Number(res.msg.yunfei * 100)
let total = (res.msg.total + res.msg.yunfei).toFixed("1");
console.log(total)
that.setData({
info: res.msg,
total: total
})
console.log('9988756', that.data.info)
fail: true
})
},
//获取页面信息
get_youfei(id) {
let that = this
let url = that.data.type == 4 ? app.interface.youfei1 : app.interface.youfei
let params = {
info: that.data.params,
address_id: id
}
app.post(url, params).then((res) => {
that.setData({
"info.yunfei": Number(res.msg.yunfei) * 100
})
return
}
if (!that.data.info.address) {
wx.showToast({
title: '请添加地址',
icon: 'none',
duration: 1000
})
},
// 支付失败弹窗关闭
payFail() {
this.setData({
fail: false
})
},
// 混合支付
mixedPay() {
let that = this
let url = app.interface.orderMixed
let params = {
order_odd: that.data.orderPayMent,
money: that.data.payMent
return
}
}
that.setData({
cover_type: !this.data.cover_type
})
},
// 去添加地址
add_address() {
wx.navigateTo({
url: '/packageA/pages/address/address',
})
},
//选择凑单商品
chooseGoods(e) {
// coudan 凑单商品组成的数组
// coudan_type 凑单的状态 可能废弃
let that = this
let coudan = this.data.coudan ? this.data.coudan : []
let coudan_arr = this.data.coudan_arr ? this.data.coudan_arr : []
let check = e.currentTarget.dataset.check
let num = e.currentTarget.dataset.num
let index = e.currentTarget.dataset.index
let id = e.currentTarget.dataset.id
let price = e.currentTarget.dataset.price;
let price2 = e.currentTarget.dataset.price2;
if (check) {
check = 0
coudan.forEach((item, index) => {
if (item.id == id) {
coudan.splice(index, 1)
coudan_arr.splice(index, 1)
}
app.post(url, params).then((res) => {
wx.requestPayment({
timeStamp: res.data.timestamp,
nonceStr: res.data.nonceStr,
package: res.data.package,
signType: 'MD5',
paySign: res.data.paySign,
success(res) {
console.log(res,'支付成功')
that.setData({
fail: false
})
wx.showToast({
title: '支付成功',
})
},
fail(res) {
console.log(res,'支付失败')
}
})
})
} else {
check = 1
//选中
coudan.push({
id: id,
num: num
})
coudan_arr.push({
id: id,
num: num,
price: Number(price),
price2:Number(price2)
})
}
that.setData({
coudan: coudan,
coudan_arr: coudan_arr,
[`info.coudanProduct[${index}].check`]: check
})
that.get_choudan()
},
//获取页面信息
get_info(type, info, id) {
let that = this
let url = type == 4 ? app.interface.prev_pay : app.interface.now_prev_pay
let params = {
info: info
}
app.post(url, params).then((res) => {
console.log('99999', res, Number(res.msg.total))
res.msg.syjf = res.msg.choudan - res.msg.yunfei
res.msg.choudan = res.msg.choudan - res.msg.yunfei
res.msg.total = Number(res.msg.total * 100)
res.msg.yunfei = Number(res.msg.yunfei * 100)
let total = (res.msg.total + res.msg.yunfei).toFixed("1");
console.log(total)
that.setData({
info: res.msg,
total:total
})
console.log('9988756', that.data.info)
})
},
//获取页面信息
get_youfei(id) {
let that = this
let url = that.data.type == 4 ? app.interface.youfei1 : app.interface.youfei
let params = {
info: that.data.params,
address_id: id
}
app.post(url, params).then((res) => {
that.setData({
"info.yunfei": Number(res.msg.yunfei)*100
})
})
},
//点击支付
submit() {
let that = this
let list = that.data.info.products
let coudan = that.data.coudan
let info = []
if (that.data.type == 4) {
for (let obj of list) {
info.push({
id: obj.product.id,
num: obj.product.num
})
},
//点击支付
submit() {
let that = this
let list = that.data.info.products
let coudan = that.data.coudan
let info = []
if (that.data.type == 4) {
for (let obj of list) {
info.push({
id: obj.product.id,
num: obj.product.num
})
}
} else {
for (let obj of list) {
info.push({
id: obj.id,
num: obj.num
})
}
}
if (coudan && coudan.length > 0) {
info = info.concat(coudan)
}
let url = app.interface.now_add
let params = {
address: that.data.info.address.id,
info: JSON.stringify(info)
}
app.post(url, params).then((res) => {
that.setData({
cover_type: false
})
that.setData({
orderPayMent: res.msg
})
that.order_pay(res.msg)
}
} else {
for (let obj of list) {
info.push({
id: obj.id,
num: obj.num
})
},
//订单支付
order_pay(order_odd) {
let that = this
let url = app.interface.order_pay
let params = {
order_odd: order_odd
}
app.post(url, params).then((res) => {
this.setData({
order: res.msg
})
if (res.msg.message == "支付成功") {
// wx.showToast({
// title: '购买成功',
// icon:'none'
// })
this.setData({
success: true
})
} else if (res.msg.message == "余额不足") {
this.setData({
fail: true
})
let payMents = (that.data.info.total + that.data.info.yunfei) / 100 - that.data.order.syjf
that.setData({
payMent: payMents.toFixed(2)
})
console.log(payMents, 'payMent')
}
}
}
if (coudan && coudan.length > 0) {
info = info.concat(coudan)
}
let url = app.interface.now_add
let params = {
address: that.data.info.address.id,
info: JSON.stringify(info)
}
app.post(url, params).then((res) => {
that.setData({
cover_type: false
})
that.order_pay(res.msg)
})
},
//订单支付
order_pay(order_odd) {
let url = app.interface.order_pay
let params = {
order_odd: order_odd
}
app.post(url, params).then((res) => {
this.setData({
order: res.msg
})
if (res.msg.message == "支付成功") {
// wx.showToast({
// title: '购买成功',
// icon:'none'
// })
this.setData({
success: true
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
console.log(options)
} else if (res.msg.message == "余额不足") {
this.setData({
type: options.type,
params: options.info
fail: true
})
this.get_info(options.type, options.info, options.id)
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
let pages = getCurrentPages();
let currPage = pages[pages.length - 1]
console.log('887766554', currPage.data.id)
if (currPage.data.id) {
console.log('4778785', this.data.info)
this.setData({
"info.address.address": currPage.data.address,
"info.address.area": currPage.data.area,
"info.address.id": currPage.data.id,
"info.address.tel": currPage.data.tel,
"info.address.name": currPage.data.name
})
console.log(this.data.info)
console.log(currPage.data.address)
this.get_youfei(currPage.data.id)
}
// if (wx.getStorageSync('no_address')) {
// wx.setStorageSync('no_address', false)
// this.setData({
// "info.address": null
// })
// }
}
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
console.log(options)
this.setData({
type: options.type,
params: options.info
})
this.get_info(options.type, options.info, options.id)
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
let pages = getCurrentPages();
let currPage = pages[pages.length - 1]
console.log('887766554',currPage.data.id)
if (currPage.data.id) {
console.log('4778785',this.data.info)
this.setData({
"info.address.address": currPage.data.address,
"info.address.area": currPage.data.area,
"info.address.id": currPage.data.id,
"info.address.tel": currPage.data.tel,
"info.address.name": currPage.data.name
})
console.log(this.data.info)
console.log(currPage.data.address)
this.get_youfei(currPage.data.id)
}
// if (wx.getStorageSync('no_address')) {
// wx.setStorageSync('no_address', false)
// this.setData({
// "info.address": null
// })
// }
},
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
}
}
})
\ No newline at end of file
... ...
<view class="content">
<!-- 地址信息 -->
<view class="address_box" wx:if="{{info.address}}" bindtap="add_address">
<view class="name">{{info.address.name}}
<text>{{info.address.tel}}</text>
<text>{{info.address.b_tel||""}}</text>
</view>
<view class="address">
<image class="tips_img" src="/images/icon_54.png" />
<view>{{info.address.area}}{{info.address.address}}</view>
</view>
<image src="/images/icon_41.png" class="youjiantou" />
</view>
<view class="on_address" wx:else bindtap="add_address">
<image src="/images/icon_46.png" />
<view>暂无收货地址,
<text>去添加</text>
</view>
<!-- 地址信息 -->
<view class="address_box" wx:if="{{info.address}}" bindtap="add_address">
<view class="name">{{info.address.name}}
<text>{{info.address.tel}}</text>
<text>{{info.address.b_tel||""}}</text>
</view>
<view class="line">
<image src="/images/line.png" />
<view class="address">
<image class="tips_img" src="/images/icon_54.png" />
<view>{{info.address.area}}{{info.address.address}}</view>
</view>
<image src="/images/icon_41.png" class="youjiantou" />
</view>
<view class="content">
<shop_item list="{{info.products}}" type="{{type}}" />
<view class='recommend' wx:if="{{info.coudanProduct.length>0}}">
<view class='re_one'>*您支付后还剩{{info.choudan}}积分为您推荐了以下凑单产品!</view>
<scroll-view class='re_goods' scroll-x scroll-left="0">
<view class='re_item' wx:for='{{info.coudanProduct}}' wx:key='index' data-index="{{index}}" data-id="{{item.id}}" data-num="{{item.num?item.num:1}}" data-check='{{item.check}}' data-price='{{item.price}}' data-price2="{{item.price2}}">
<view class='re_re_item {{item.check?"active":""}}'>
<view class='triangle' wx:if='{{item.check}}'>
<image src='/images/bingo.png' class='bingo'></image>
</view>
<view class='re_re_img'>
<image src='{{item.images[0]}}' mode='aspectFill'></image>
</view>
<view class='re_bottom'>
<view class='re_re_name'>{{item.name}}</view>
<view class='re_re_score' wx:if="{{item.price!=null}}">{{item.price2}}积分</view>
<view class='re_re_score' wx:else>{{item.price}}积分</view>
</view>
<!-- 数量操作 -->
<view class="num_box">
<image class="num_btn" src="/images/reduce.png" data-check='{{item.check}}' wx:if="{{item.num}}" data-index="{{index}}" data-id="{{item.id}}" data-type="0" data-num="{{item.num?item.num:0}}" catchtap="num_change" data-price='{{item.price}}' data-price2="{{item.price2}}" />
<text wx:if="{{item.num}}">{{item.num?item.num:0}}</text>
<image class="num_btn" src="/images/add.png" data-check='{{item.check}}' data-index="{{index}}" data-id="{{item.id}}" data-type="1" data-num="{{item.num?item.num:0}}" catchtap="num_change" data-price='{{item.price}}' data-price2="{{item.price2}}" />
</view>
</view>
</view>
</scroll-view>
</view>
<view class="on_address" wx:else bindtap="add_address">
<image src="/images/icon_46.png" />
<view>暂无收货地址,
<text>去添加</text>
</view>
</view>
<view class="line">
<image src="/images/line.png" />
</view>
<view class='three'>
<view class='mask_two'>
<view>订单编号</view>
<view class='score'>{{info.order_odd}}</view>
<view class="content">
<shop_item list="{{info.products}}" type="{{type}}" />
<view class='recommend' wx:if="{{info.coudanProduct.length>0}}">
<view class='re_one'>*您支付后还剩{{info.choudan}}积分为您推荐了以下凑单产品!</view>
<scroll-view class='re_goods' scroll-x scroll-left="0">
<view class='re_item' wx:for='{{info.coudanProduct}}' wx:key='index' data-index="{{index}}" data-id="{{item.id}}" data-num="{{item.num?item.num:1}}" data-check='{{item.check}}' data-price='{{item.price}}' data-price2="{{item.price2}}">
<view class='re_re_item {{item.check?"active":""}}'>
<view class='triangle' wx:if='{{item.check}}'>
<image src='/images/bingo.png' class='bingo'></image>
</view>
<view class='mask_two'>
<view>创建时间</view>
<view class='score'>{{info.date}}</view>
<view class='re_re_img'>
<image src='{{item.images[0]}}' mode='aspectFill'></image>
</view>
<view class='re_bottom'>
<view class='re_re_name'>{{item.name}}</view>
<view class='re_re_score'wx:if="{{item.price!=null}}">{{item.price2}}积分</view>
<view class='re_re_score' wx:else>{{item.price}}积分</view>
</view>
<view class='mask_two'>
<view>邮费</view>
<view class='score' style="color:rgba(242, 0, 0, 1)">{{info.yunfei/100}}积分</view>
<!-- 数量操作 -->
<view class="num_box">
<image class="num_btn" src="/images/reduce.png" data-check='{{item.check}}' wx:if="{{item.num}}" data-index="{{index}}" data-id="{{item.id}}" data-type="0" data-num="{{item.num?item.num:0}}" catchtap="num_change" data-price='{{item.price}}' data-price2="{{item.price2}}" />
<text wx:if="{{item.num}}" >{{item.num?item.num:0}}</text>
<image class="num_btn" src="/images/add.png" data-check='{{item.check}}' data-index="{{index}}" data-id="{{item.id}}" data-type="1" data-num="{{item.num?item.num:0}}" catchtap="num_change" data-price='{{item.price}}' data-price2="{{item.price2}}" />
</view>
</view>
</view>
</scroll-view>
</view>
<view class='three'>
<view class='mask_two'>
<view>订单编号</view>
<view class='score'>{{info.order_odd}}</view>
</view>
<view class='mask_two'>
<view>创建时间</view>
<view class='score'>{{info.date}}</view>
</view>
<view class='mask_two'>
<view>邮费</view>
<view class='score' style="color:rgba(242, 0, 0, 1)">{{info.yunfei/100}}积分</view>
</view>
</view>
</view>
</view>
<view class="footer">
<view class="submit" catchtap="show_cover">提交</view>
<view class="jifen"> 合计:
<!-- <text>{{choudan_money?choudan_money + info.total + info.yunfei*100/100: info.total + info.yunfei*100/100}}积分</text> -->
<text>{{choudan_money?(choudan_money + info.total + info.yunfei)/100: (info.total + info.yunfei)/100}}积分</text>
</view>
<view class="num">共{{info.totalnum + choudanNum}}件</view>
<view class="submit" catchtap="show_cover">提交</view>
<view class="jifen"> 合计:
<!-- <text>{{choudan_money?choudan_money + info.total + info.yunfei*100/100: info.total + info.yunfei*100/100}}积分</text> -->
<text>{{choudan_money?(choudan_money + info.total + info.yunfei)/100: (info.total + info.yunfei)/100}}积分</text>
</view>
<view class="num">共{{info.totalnum + choudanNum}}件</view>
</view>
<concat />
<concat/>
<!-- 支付成功弹框开始 -->
<view class='success_mask' wx:if='{{success}}'>
<view class='success_diceng'>
<view class='success_one'>
<image src='/images/success.png'></image>
</view>
<view class='success_font'>支付成功</view>
<navigator class='success_confirm_btn' open-type="navigateBack">确定</navigator>
<view class='success_diceng'>
<view class='success_one'>
<image src='/images/success.png'></image>
</view>
<view class='success_font'>支付成功</view>
<navigator class='success_confirm_btn' open-type="navigateBack">确定</navigator>
</view>
</view>
<!-- 支付成功弹框结束 -->
<!-- 支付失败弹框开始 -->
<!-- <view class='success_mask' wx:if='{{fail}}'>
<view class='success_mask' wx:if='{{fail}}'>
<view class='success_diceng'>
<view class='success_one'>
<image src='/images/icon_55.png'></image>
</view>
<view class='success_font'>支付失败</view>
status为1的时候才能支付
<!-- status为1的时候才能支付 -->
<view class='fail_font' wx:if="{{info.status == 0}}">不在活动时间,您不能支付</view>
<view class='fail_font' wx:else>所需积分{{order.xy}},积分余额{{order.syjf}}</view>
<navigator class='success_confirm_btn' open-type="navigateBack">取消支付</navigator>
</view>
</view> -->
<view class="peijianMask" wx-if="{{fail}}">
<view class="peijianPopup">
<view class="typePopop_quxiao" bindtap="payFail">
<image src="/images/quxiao11.png" mode="widthFix" style="width: 48rpx;"></image>
</view>
<view style="padding: 32rpx;margin-top: 80rpx;">
<view style="display: flex;flex-direction: column;align-items: center;">
<image src="/images/jinggao.png" mode="widthFix" style="width: 126rpx;"></image>
<text style="font-size: 32rpx; color: #000;margin: 16rpx 0;">支付失败</text>
<text style="font-size: 28rpx;">您的积分不足,可使用微信支付差价</text>
</view>
<view style="width: 100%;padding: 32rpx 0;display: flex;justify-content: space-between;border-bottom: 1rpx solid rgba(240,242,245,1);">
<view style="font-size: 28rpx;">
共需积分
</view>
<view style="font-size: 32rpx;color: #3D9BF5;">
{{order.xy}}
</view>
</view>
<view style="width: 100%;padding: 32rpx 0;display: flex;justify-content: space-between;border-bottom: 1rpx solid rgba(240,242,245,1);">
<view style="font-size: 28rpx;">
当前积分
</view>
<view style="font-size: 32rpx;color: #3D9BF5;">
{{order.syjf}}
</view>
</view>
<view style="width: 100%;padding: 32rpx 0;display: flex;justify-content: space-between;border-bottom: 1rpx solid rgba(240,242,245,1);">
<view style="font-size: 28rpx;">
差价支付
</view>
<view style="font-size: 32rpx;color: #ED261C;">
¥{{payMent}}
</view>
</view>
<view style="margin-top: 114rpx;display: flex;align-items: center;font-size: 28rpx;justify-content: space-between;">
<view>
<text style="color: rgba(0,0,0,0.26);">共{{info.totalnum + choudanNum}}件,</text>
<text style="color: rgba(0,0,0,0.6);">合计:</text>
<text style="color: #3D9BF5;">{{order.xy}}积分,</text>
<text style="color: rgba(0,0,0,0.6);">差价:</text>
<text style="color: #ED261C;">¥{{payMent}}</text>
</view>
<view style="width: 222rpx;height: 88rpx;background-color: #3D9BF5;border-radius: 96rpx;display: flex;align-items: center;justify-content: center;font-size: 32rpx;color: #FFFFFF;" bindtap="mixedPay">
提交
</view>
</view>
</view>
</view>
</view>
<!-- 支付失败弹框结束 -->
<view class="cover_box" wx:if="{{cover_type}}">
<view class="cover_order">
<view class="all_money">{{choudan_money?(choudan_money + info.total + info.yunfei)/100: (info.total + info.yunfei)/100}}积分</view>
<view class="money_item">
<text>商品积分</text>
<text>{{choudan_money?(choudan_money + info.total)/100:info.total/100}}积分</text>
</view>
<view class="money_item">
<text>邮费</text>
<text>{{info.yunfei/100}}积分</text>
</view>
<view class="cover_submit" catchtap="submit">确认支付</view>
<image src="/images/close.png" class="cover_close" catchtap="show_cover" />
<view class="cover_order">
<view class="all_money">{{choudan_money?(choudan_money + info.total + info.yunfei)/100: (info.total + info.yunfei)/100}}积分</view>
<view class="money_item">
<text>商品积分</text>
<text>{{choudan_money?(choudan_money + info.total)/100:info.total/100}}积分</text>
</view>
<view class="money_item">
<text>邮费</text>
<text>{{info.yunfei/100}}积分</text>
</view>
<view class="cover_submit" catchtap="submit">确认支付</view>
<image src="/images/close.png" class="cover_close" catchtap="show_cover" />
</view>
</view>
\ No newline at end of file
... ...
... ... @@ -18,7 +18,7 @@ Page({
},
// 展示待支付的去支付弹窗
show_cover(e) {
if( app.globalData.status==0){
if( a.globalData.status==0){
wx.showToast({
title: '您已您所在单位暂未开始劳保购买!',
icon:'none'
... ...
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
success: false,
fail: false,
name: '',
choudanNum: 0,
addressId: 0,
tel: '',
area: '',
address: '',
cover_type: false,
total: '',
payMent: '',
orderPayMent: '',
info: {
address: {
address: '',
area: '',
id: '',
tel: '',
name: ''
}
}
},
//加减商品数量
num_change(e) {
let that = this
let num = Number(e.currentTarget.dataset.num)
console.log(num)
let type = e.currentTarget.dataset.type
let index = e.currentTarget.dataset.index
let id = e.currentTarget.dataset.id
let check = e.currentTarget.dataset.check
let coudan = this.data.coudan || []
let coudan_arr = this.data.coudan_arr || []
let price = e.currentTarget.dataset.price;
let price2 = e.currentTarget.dataset.price2;
if (type == 1) {
if (this.data.info.choudan * 100 < (price * 100)) {
wx.showToast({
title: '当前剩余积分不足,请重新挑选',
icon: 'none'
})
return
}
num++
} else {
num--
if (num < 0) {
num = 0;
return
}
}
if (num < 1) {
coudan.forEach((item, index) => {
if (item.id == id) {
coudan.splice(index, 1)
coudan_arr.splice(index, 1)
}
})
} else {
if (type == 1 && num == 1) {
//选中
coudan.push({
id: id,
num: num
})
coudan_arr.push({
id: id,
num: num,
price: Number(price),
price2: Number(price2)
})
} else {
coudan.forEach((item, index) => {
if (item.id == id) {
item.num = num
coudan_arr[index].num = num
}
})
}
}
that.setData({
coudan: coudan,
coudan_arr: coudan_arr,
[`info.coudanProduct[${index}].num`]: num
// [`info.coudanProduct[${index}].check`]: check
})
this.get_choudan()
},
// 计算凑单费用
get_choudan() {
let coudan_arr = this.data.coudan_arr
let choudan_money = 0;
let num = 0
for (let obj of coudan_arr) {
console.log(obj)
console.log(obj.price2)
if (obj.price2 != null) {
console.log(111)
choudan_money = (obj.price2 * 100 * obj.num) / 100 + choudan_money
} else {
console.log(222)
choudan_money = (obj.price * 100 * obj.num) / 100 + choudan_money
}
num = num + obj.num
}
this.setData({
choudan_money: choudan_money * 100,
choudanNum: num,
'info.choudan': this.data.info.syjf - choudan_money
// choudan_money: Math.floor(choudan_money* 100) / 100
})
},
show_cover() {
let that = this
if (!that.data.cover_type) {
if (that.data.info.status == 0) {
that.setData({
fail: true
})
return
}
if (!that.data.info.address) {
wx.showToast({
title: '请添加地址',
icon: 'none',
duration: 1000
})
return
}
}
that.setData({
cover_type: !this.data.cover_type
})
},
// 去添加地址
add_address() {
wx.navigateTo({
url: '/pages/address/address',
})
},
//选择凑单商品
chooseGoods(e) {
// coudan 凑单商品组成的数组
// coudan_type 凑单的状态 可能废弃
let that = this
let coudan = this.data.coudan ? this.data.coudan : []
let coudan_arr = this.data.coudan_arr ? this.data.coudan_arr : []
let check = e.currentTarget.dataset.check
let num = e.currentTarget.dataset.num
let index = e.currentTarget.dataset.index
let id = e.currentTarget.dataset.id
let price = e.currentTarget.dataset.price;
let price2 = e.currentTarget.dataset.price2;
if (check) {
check = 0
coudan.forEach((item, index) => {
if (item.id == id) {
coudan.splice(index, 1)
coudan_arr.splice(index, 1)
}
})
} else {
check = 1
//选中
coudan.push({
id: id,
num: num
})
coudan_arr.push({
id: id,
num: num,
price: Number(price),
price2: Number(price2)
})
}
that.setData({
coudan: coudan,
coudan_arr: coudan_arr,
[`info.coudanProduct[${index}].check`]: check
})
that.get_choudan()
},
//获取页面信息
get_info(type, info, id) {
let that = this
let url = type == 4 ? app.interface.prev_pay : app.interface.now_prev_pay
let params = {
info: info
}
app.post(url, params).then((res) => {
console.log('99999', res, Number(res.msg.total))
res.msg.syjf = res.msg.choudan - res.msg.yunfei
let a = (res.msg.choudan - res.msg.yunfei).toFixed(2)
if (a < 0) {
a = 0
}
res.msg.choudan = a
res.msg.total = Number(res.msg.total * 100)
res.msg.yunfei = Number(res.msg.yunfei * 100)
let total = (res.msg.total + res.msg.yunfei).toFixed("1");
console.log(total)
that.setData({
info: res.msg,
total: total
})
console.log('9988756', that.data.info)
})
},
//获取页面信息
get_youfei(id) {
let that = this
let url = that.data.type == 4 ? app.interface.youfei1 : app.interface.youfei
let params = {
info: that.data.params,
address_id: id
}
app.post(url, params).then((res) => {
that.setData({
"info.yunfei": Number(res.msg.yunfei) * 100
})
})
},
// 支付失败弹窗关闭
payFail() {
this.setData({
fail: false
})
},
// 混合支付
mixedPay() {
let that = this
let url = app.interface.orderMixed
let params = {
order_odd: that.data.orderPayMent,
money: that.data.payMent
}
app.post(url, params).then((res) => {
wx.requestPayment({
timeStamp: res.data.timestamp,
nonceStr: res.data.nonceStr,
package: res.data.package,
signType: 'MD5',
paySign: res.data.paySign,
success(res) {
console.log(res,'支付成功')
that.setData({
fail: false
})
wx.showToast({
title: '支付成功',
})
},
fail(res) {
console.log(res,'支付失败')
}
})
})
},
//点击支付
submit() {
let that = this
let list = that.data.info.products
let coudan = that.data.coudan
let info = []
if (that.data.type == 4) {
for (let obj of list) {
info.push({
id: obj.product.id,
num: obj.product.num
})
}
} else {
for (let obj of list) {
info.push({
id: obj.id,
num: obj.num
})
}
}
if (coudan && coudan.length > 0) {
info = info.concat(coudan)
}
let url = app.interface.now_add
let params = {
address: that.data.info.address.id,
info: JSON.stringify(info)
}
app.post(url, params).then((res) => {
that.setData({
cover_type: false
})
that.setData({
orderPayMent: res.msg
})
that.order_pay(res.msg)
})
},
//订单支付
order_pay(order_odd) {
let that = this
let url = app.interface.order_pay
let params = {
order_odd: order_odd
}
app.post(url, params).then((res) => {
this.setData({
order: res.msg
})
if (res.msg.message == "支付成功") {
// wx.showToast({
// title: '购买成功',
// icon:'none'
// })
this.setData({
success: true
})
} else if (res.msg.message == "余额不足") {
this.setData({
fail: true
})
let payMents = (that.data.info.total + that.data.info.yunfei) / 100 - that.data.order.syjf
that.setData({
payMent: payMents.toFixed(2)
})
console.log(payMents, 'payMent')
}
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
console.log(options)
this.setData({
type: options.type,
params: options.info
})
this.get_info(options.type, options.info, options.id)
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
let pages = getCurrentPages();
let currPage = pages[pages.length - 1]
console.log('887766554', currPage.data.id)
if (currPage.data.id) {
console.log('4778785', this.data.info)
this.setData({
"info.address.address": currPage.data.address,
"info.address.area": currPage.data.area,
"info.address.id": currPage.data.id,
"info.address.tel": currPage.data.tel,
"info.address.name": currPage.data.name
})
console.log(this.data.info)
console.log(currPage.data.address)
this.get_youfei(currPage.data.id)
}
// if (wx.getStorageSync('no_address')) {
// wx.setStorageSync('no_address', false)
// this.setData({
// "info.address": null
// })
// }
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
<view class="content">
<!-- 地址信息 -->
<view class="address_box" wx:if="{{info.address}}" bindtap="add_address">
<view class="name">{{info.address.name}}
<text>{{info.address.tel}}</text>
<text>{{info.address.b_tel||""}}</text>
</view>
<view class="address">
<image class="tips_img" src="/images/icon_54.png" />
<view>{{info.address.area}}{{info.address.address}}</view>
</view>
<image src="/images/icon_41.png" class="youjiantou" />
</view>
<view class="on_address" wx:else bindtap="add_address">
<image src="/images/icon_46.png" />
<view>暂无收货地址,
<text>去添加</text>
</view>
</view>
<view class="line">
<image src="/images/line.png" />
</view>
<view class="content">
<shop_item list="{{info.products}}" type="{{type}}" />
<view class='recommend' wx:if="{{info.coudanProduct.length>0}}">
<view class='re_one'>*您支付后还剩{{info.choudan}}积分为您推荐了以下凑单产品!</view>
<scroll-view class='re_goods' scroll-x scroll-left="0">
<view class='re_item' wx:for='{{info.coudanProduct}}' wx:key='index' data-index="{{index}}" data-id="{{item.id}}" data-num="{{item.num?item.num:1}}" data-check='{{item.check}}' data-price='{{item.price}}' data-price2="{{item.price2}}">
<view class='re_re_item {{item.check?"active":""}}'>
<view class='triangle' wx:if='{{item.check}}'>
<image src='/images/bingo.png' class='bingo'></image>
</view>
<view class='re_re_img'>
<image src='{{item.images[0]}}' mode='aspectFill'></image>
</view>
<view class='re_bottom'>
<view class='re_re_name'>{{item.name}}</view>
<view class='re_re_score' wx:if="{{item.price!=null}}">{{item.price2}}积分</view>
<view class='re_re_score' wx:else>{{item.price}}积分</view>
</view>
<!-- 数量操作 -->
<view class="num_box">
<image class="num_btn" src="/images/reduce.png" data-check='{{item.check}}' wx:if="{{item.num}}" data-index="{{index}}" data-id="{{item.id}}" data-type="0" data-num="{{item.num?item.num:0}}" catchtap="num_change" data-price='{{item.price}}' data-price2="{{item.price2}}" />
<text wx:if="{{item.num}}">{{item.num?item.num:0}}</text>
<image class="num_btn" src="/images/add.png" data-check='{{item.check}}' data-index="{{index}}" data-id="{{item.id}}" data-type="1" data-num="{{item.num?item.num:0}}" catchtap="num_change" data-price='{{item.price}}' data-price2="{{item.price2}}" />
</view>
</view>
</view>
</scroll-view>
</view>
<view class='three'>
<view class='mask_two'>
<view>订单编号</view>
<view class='score'>{{info.order_odd}}</view>
</view>
<view class='mask_two'>
<view>创建时间</view>
<view class='score'>{{info.date}}</view>
</view>
<view class='mask_two'>
<view>邮费</view>
<view class='score' style="color:rgba(242, 0, 0, 1)">{{info.yunfei/100}}积分</view>
</view>
</view>
</view>
</view>
<view class="footer">
<view class="submit" catchtap="show_cover">提交</view>
<view class="jifen"> 合计:
<!-- <text>{{choudan_money?choudan_money + info.total + info.yunfei*100/100: info.total + info.yunfei*100/100}}积分</text> -->
<text>{{choudan_money?(choudan_money + info.total + info.yunfei)/100: (info.total + info.yunfei)/100}}积分</text>
</view>
<view class="num">共{{info.totalnum + choudanNum}}件</view>
</view>
<concat />
<!-- 支付成功弹框开始 -->
<view class='success_mask' wx:if='{{success}}'>
<view class='success_diceng'>
<view class='success_one'>
<image src='/images/success.png'></image>
</view>
<view class='success_font'>支付成功</view>
<navigator class='success_confirm_btn' open-type="navigateBack">确定</navigator>
</view>
</view>
<!-- 支付成功弹框结束 -->
<!-- 支付失败弹框开始 -->
<!-- <view class='success_mask' wx:if='{{fail}}'>
<view class='success_diceng'>
<view class='success_one'>
<image src='/images/icon_55.png'></image>
</view>
<view class='success_font'>支付失败</view>
status为1的时候才能支付
<view class='fail_font' wx:if="{{info.status == 0}}">不在活动时间,您不能支付</view>
<view class='fail_font' wx:else>所需积分{{order.xy}},积分余额{{order.syjf}}</view>
<navigator class='success_confirm_btn' open-type="navigateBack">取消支付</navigator>
</view>
</view> -->
<view class="peijianMask" wx-if="{{fail}}">
<view class="peijianPopup">
<view class="typePopop_quxiao" bindtap="payFail">
<image src="/images/quxiao11.png" mode="widthFix" style="width: 48rpx;"></image>
</view>
<view style="padding: 32rpx;margin-top: 80rpx;">
<view style="display: flex;flex-direction: column;align-items: center;">
<image src="/images/jinggao.png" mode="widthFix" style="width: 126rpx;"></image>
<text style="font-size: 32rpx; color: #000;margin: 16rpx 0;">支付失败</text>
<text style="font-size: 28rpx;">您的积分不足,可使用微信支付差价</text>
</view>
<view style="width: 100%;padding: 32rpx 0;display: flex;justify-content: space-between;border-bottom: 1rpx solid rgba(240,242,245,1);">
<view style="font-size: 28rpx;">
共需积分
</view>
<view style="font-size: 32rpx;color: #3D9BF5;">
{{order.xy}}
</view>
</view>
<view style="width: 100%;padding: 32rpx 0;display: flex;justify-content: space-between;border-bottom: 1rpx solid rgba(240,242,245,1);">
<view style="font-size: 28rpx;">
当前积分
</view>
<view style="font-size: 32rpx;color: #3D9BF5;">
{{order.syjf}}
</view>
</view>
<view style="width: 100%;padding: 32rpx 0;display: flex;justify-content: space-between;border-bottom: 1rpx solid rgba(240,242,245,1);">
<view style="font-size: 28rpx;">
差价支付
</view>
<view style="font-size: 32rpx;color: #ED261C;">
¥{{payMent}}
</view>
</view>
<view style="margin-top: 114rpx;display: flex;align-items: center;font-size: 28rpx;justify-content: space-between;">
<view>
<text style="color: rgba(0,0,0,0.26);">共{{info.totalnum + choudanNum}}件,</text>
<text style="color: rgba(0,0,0,0.6);">合计:</text>
<text style="color: #3D9BF5;">{{order.xy}}积分,</text>
<text style="color: rgba(0,0,0,0.6);">差价:</text>
<text style="color: #ED261C;">¥{{payMent}}</text>
</view>
<view style="width: 222rpx;height: 88rpx;background-color: #3D9BF5;border-radius: 96rpx;display: flex;align-items: center;justify-content: center;font-size: 32rpx;color: #FFFFFF;" bindtap="mixedPay">
提交
</view>
</view>
</view>
</view>
</view>
<!-- 支付失败弹框结束 -->
<view class="cover_box" wx:if="{{cover_type}}">
<view class="cover_order">
<view class="all_money">{{choudan_money?(choudan_money + info.total + info.yunfei)/100: (info.total + info.yunfei)/100}}积分</view>
<view class="money_item">
<text>商品积分</text>
<text>{{choudan_money?(choudan_money + info.total)/100:info.total/100}}积分</text>
</view>
<view class="money_item">
<text>邮费</text>
<text>{{info.yunfei/100}}积分</text>
</view>
<view class="cover_submit" catchtap="submit">确认支付</view>
<image src="/images/close.png" class="cover_close" catchtap="show_cover" />
</view>
</view>
\ No newline at end of file
... ...
... ... @@ -11,7 +11,7 @@
</view>
<view class="btn_box">
<view class="check" data-id="{{item.id}}" data-index="{{index}}" wx:if="{{item.mo != 1}}" catchtap="mrAddressFun">
<image wx:if="{{item.is_default==2}}" src="/images/check.png" />
<image wx:if="{{!item.check}}" src="/images/check.png" />
<image wx:else src="/images/check@.png" /> 设为默认地址
</view>
<block>
... ...
... ... @@ -321,7 +321,7 @@ Page({
onLoad: function (options) {
console.log(app.globalData.index)
wx.setStorageSync('entrance_type', 0)
if (app.globalData.index == undefined) {
let that = this;
let token = wx.getStorageSync('token');
... ... @@ -1111,7 +1111,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function () {
wx.setStorageSync('entrance_type', 0)
this.setData({
logok: app.globalData.baseUrlimg + "assets/img/cb2ad36a391388f19f5f912fa021f8f.png"
})
... ...