|
@@ -47,7 +47,7 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="goods-cart w-full">
|
|
|
- <view class="goods-cont padding-tb" v-for="(item, index) in data.carlist" :key="index">
|
|
|
+ <view class="goods-cont padding-tb" v-for="(item, index) in cartData" :key="index">
|
|
|
<my-goods :item="item">
|
|
|
<view class="good-num">×{{item.quantity}}</view>
|
|
|
</my-goods>
|
|
@@ -60,7 +60,7 @@
|
|
|
<view class="bg-main">
|
|
|
<view class="dflex-b padding-lr padding-tb-sm">
|
|
|
<view class="flex1">总金额</view>
|
|
|
- <view class="price">{{data.total}}</view>
|
|
|
+ <view class="price">{{total}}</view>
|
|
|
</view>
|
|
|
<!-- <view class="dflex-b padding-lr padding-tb-sm">
|
|
|
<view class="flex1">运费 (总重:4.960 kg )</view>
|
|
@@ -88,12 +88,16 @@
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
+ cartData:[],
|
|
|
+ total: 0,
|
|
|
data: [],
|
|
|
show: false,
|
|
|
value: '',
|
|
|
+ bussinessInfo:{},
|
|
|
cList: {},
|
|
|
val: null,
|
|
|
vals: null,
|
|
|
+ tenantId:'',
|
|
|
list: [{
|
|
|
text: "店内用餐",
|
|
|
value: 0
|
|
@@ -108,20 +112,44 @@
|
|
|
onLoad(option) {
|
|
|
const e = uni.getStorageSync('carl')
|
|
|
this.cList = e
|
|
|
- console.log('233333333333333', e)
|
|
|
- // 解码 URL 编码的字符串
|
|
|
- var dataString = decodeURIComponent(option.data);
|
|
|
- // 尝试将字符串转换为 JSON 对象
|
|
|
- var data = JSON.parse(dataString);
|
|
|
- if(data.carlist[0].imgUrl.url) {
|
|
|
- data.carlist[0].imgUrl = data.carlist[0].imgUrl.url;
|
|
|
- }
|
|
|
+ // console.log('233333333333333', e)
|
|
|
+ // // 解码 URL 编码的字符串
|
|
|
+ // var dataString = decodeURIComponent(option.data);
|
|
|
+ // // 尝试将字符串转换为 JSON 对象
|
|
|
+ // var data = JSON.parse(dataString);
|
|
|
+ // if(data.carlist[0].imgUrl.url) {
|
|
|
+ // data.carlist[0].imgUrl = data.carlist[0].imgUrl.url;
|
|
|
+ // }
|
|
|
+
|
|
|
+ // this.data = data
|
|
|
+ // // 打印解码后的数据
|
|
|
+ // console.log('eeeeeeeeeeeee============data', data);
|
|
|
|
|
|
- this.data = data
|
|
|
- // 打印解码后的数据
|
|
|
- console.log('eeeeeeeeeeeee============data', data);
|
|
|
+ const config = process.env.ENV_PATH ? require('../../../' + process.env.ENV_PATH) : require(
|
|
|
+ '../../../env/dev.js');
|
|
|
+ this.tenantId = config.tenantId;
|
|
|
+ this.initCart()
|
|
|
+ // this.loadBussinessInfo()
|
|
|
},
|
|
|
methods: {
|
|
|
+ initCart() {
|
|
|
+ let cartInfo = uni.getStorageSync('cartInfo');
|
|
|
+ if(cartInfo){
|
|
|
+ try{
|
|
|
+ this.cartData = JSON.parse(cartInfo)
|
|
|
+ this.totalPrice()
|
|
|
+ }catch(e){}
|
|
|
+ }
|
|
|
+ },
|
|
|
+ totalPrice() {
|
|
|
+ let total = 0;
|
|
|
+ for (let i = 0; i < this.cartData.length; i++) {
|
|
|
+ let priceInCents = Math.round(this.carList[i].price * 100);
|
|
|
+ let quant = this.carList[i].quantity;
|
|
|
+ total += priceInCents * quant;
|
|
|
+ }
|
|
|
+ this.total = (total / 100).toFixed(2);
|
|
|
+ },
|
|
|
sendTypeChange(v) {},
|
|
|
radioChange(v) {
|
|
|
console.log('2=================', v)
|
|
@@ -155,7 +183,7 @@
|
|
|
}
|
|
|
const userId = uni.getStorageSync('appUserId');
|
|
|
const userName = uni.getStorageSync('userName');
|
|
|
- const itemListArray = this.data.carlist.map(item => ({
|
|
|
+ const itemListArray = this.cartData.map(item => ({
|
|
|
skuId: item.skuId,
|
|
|
gift: 1, // 假设所有商品都不是礼物
|
|
|
basePrice: Number(item.basePrice),
|
|
@@ -168,32 +196,42 @@
|
|
|
picUrl: item.imgUrl,
|
|
|
skuProperties: item.skuProperties,
|
|
|
totalFee: multiply(Number(item.price), item.quantity),
|
|
|
- adjustFee: 0
|
|
|
+ adjustFee: 0,
|
|
|
+ skuCode: item.skuCode,
|
|
|
+ splitMergeId: item.splitMergeId,
|
|
|
+ productWeight: item.productWeight,
|
|
|
+ freightTemplateId: item.freightTemplateId
|
|
|
}))
|
|
|
|
|
|
const params = {
|
|
|
- orderState: 1,
|
|
|
+ buyerRate:'1',
|
|
|
+ distributionOrder:'1',
|
|
|
+ orderState: 'WaitPay',
|
|
|
+ partConsign:'1',
|
|
|
orderType: 1,
|
|
|
- serviceType: 1,
|
|
|
- payAmount: Number(this.data.total),
|
|
|
- totalAmount: Number(this.data.total),
|
|
|
+ serviceType: '1',
|
|
|
+ payAmount: Number(this.total),
|
|
|
+ totalAmount: Number(this.total),
|
|
|
discountAmount: 0,
|
|
|
adjustAmount: 0,
|
|
|
postAmount: 0,
|
|
|
- receivedAmount: Number(this.data.total),
|
|
|
+ receivedAmount: Number(this.total),
|
|
|
commissionAmount: 0,
|
|
|
payOnDeliveryAmount: 0,
|
|
|
- payOnDelivery: 1,
|
|
|
- payType: 1,
|
|
|
- payChannel: 1,
|
|
|
- invoice: 1,
|
|
|
+ payOnDelivery: '1',
|
|
|
+ payType: '1',
|
|
|
+ payChannel: '1',
|
|
|
+ invoice: '1',
|
|
|
+ orderSource:'2',
|
|
|
storeId: this.cList.id,
|
|
|
storeName: this.cList.name,
|
|
|
sellerNick: this.cList.name,
|
|
|
+ sellerId: this.bussinessInfo.id,
|
|
|
buyerNick: userName,
|
|
|
customerId: userId,
|
|
|
+ sellerRate:'1',
|
|
|
orderItemList: itemListArray,
|
|
|
- shippingType: 4,
|
|
|
+ shippingType: '4',
|
|
|
orderPickup: {
|
|
|
pickupType: this.val,
|
|
|
verify: 2,
|
|
@@ -204,28 +242,32 @@
|
|
|
// uni.navigateTo({
|
|
|
// url: `/pages/order/orderPaid/orderPaid`
|
|
|
// })
|
|
|
+ return
|
|
|
+ const that = this;
|
|
|
this.$request('post', `/order/tradeOrder/addTradeOrder`, params, true).then(response => {
|
|
|
// 请求成功
|
|
|
console.log('response', response)
|
|
|
if (response.code == 200) {
|
|
|
- const ids = this.data.carlist.map(car => car.id);
|
|
|
- this.$request('delete', `/front/shoppingCart/${ids}`)
|
|
|
- console.log('response.data', response.data)
|
|
|
- uni.$emit('register_refresh');
|
|
|
- uni.showToast({
|
|
|
- title: '已下单,因目前是演示阶段,暂时不能付款',
|
|
|
- icon: 'success',
|
|
|
- duration: 2000,
|
|
|
- complete: () => {
|
|
|
- // 页面跳转放在complete回调中
|
|
|
- uni.navigateTo({
|
|
|
- url: `/pages/order/myOrder/myOrder?type=0`
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- // uni.navigateTo({
|
|
|
- // url: `/pages/order/orderPaid/orderPaid?id=${response.data}`
|
|
|
+ // const ids = this.data.carlist.map(car => car.id);
|
|
|
+ // this.$request('delete', `/front/shoppingCart/${ids}`)
|
|
|
+ // console.log('response.data', response.data)
|
|
|
+ // uni.$emit('register_refresh');
|
|
|
+ // uni.showToast({
|
|
|
+ // title: '已下单,因目前是演示阶段,暂时不能付款',
|
|
|
+ // icon: 'success',
|
|
|
+ // duration: 2000,
|
|
|
+ // complete: () => {
|
|
|
+ // // 页面跳转放在complete回调中
|
|
|
+ // uni.navigateTo({
|
|
|
+ // url: `/pages/order/myOrder/myOrder?type=0`
|
|
|
+ // })
|
|
|
+ // }
|
|
|
// })
|
|
|
+ // // uni.navigateTo({
|
|
|
+ // // url: `/pages/order/orderPaid/orderPaid?id=${response.data}`
|
|
|
+ // // })
|
|
|
+ uni.removeStorageSync('cartInfo');
|
|
|
+ that.pay(response.msg)
|
|
|
} else if (response.code == 500) {
|
|
|
uni.showToast({
|
|
|
title: response.msg,
|
|
@@ -237,6 +279,90 @@
|
|
|
// 请求失败
|
|
|
console.error('请求失败:', error);
|
|
|
})
|
|
|
+ },
|
|
|
+ //获取商家信息
|
|
|
+ loadBussinessInfo() {
|
|
|
+ const that = this;
|
|
|
+ this.$req({
|
|
|
+ url: '/sale/business/queryBusiness',
|
|
|
+ method: 'GET',
|
|
|
+ data: {
|
|
|
+ pageNum: 1, //当前页
|
|
|
+ pageSize: 20 //每页条数
|
|
|
+ },
|
|
|
+ success: res => {
|
|
|
+ that.bussinessInfo = res.rows[0]
|
|
|
+ },
|
|
|
+ fail: err => {
|
|
|
+ let msg = ''
|
|
|
+ if (err && err.msg && err.msg.length < 15) {
|
|
|
+ msg = err.msg
|
|
|
+ } else {
|
|
|
+ msg = '系统繁忙'
|
|
|
+ }
|
|
|
+ that.$refs.uToast.show({
|
|
|
+ message: msg
|
|
|
+ })
|
|
|
+ },
|
|
|
+ complete: () => {
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //支付
|
|
|
+ pay(id) {
|
|
|
+ let that = this;
|
|
|
+ const openId = uni.getStorageSync("openId");
|
|
|
+ // let outTradeNo = this.uuid()
|
|
|
+ this.$req({
|
|
|
+ url: '/weChatPay/payment/miniPay',
|
|
|
+ method: 'POST',
|
|
|
+ data: {
|
|
|
+ tenantId: this.tenantId,
|
|
|
+ outTradeNo: id,
|
|
|
+ openId: openId,
|
|
|
+ total: this.totalPrice * 100,
|
|
|
+ },
|
|
|
+ other: res => {
|
|
|
+ wx.requestPayment({
|
|
|
+ "timeStamp": res.timeStamp,
|
|
|
+ "nonceStr": res.nonceStr,
|
|
|
+ "package": res.packageValue,
|
|
|
+ "signType": "RSA",
|
|
|
+ "paySign": res.paySign,
|
|
|
+ "success": function(res) {
|
|
|
+ // console.log('调用支付接口成功', res)
|
|
|
+ // that.$refs.uToast.show({
|
|
|
+ // type:'success',
|
|
|
+ // message: '操作成功!'
|
|
|
+ // })
|
|
|
+ uni.redirectTo({
|
|
|
+ url: '/pages/order/paySuccess/paySuccess?price=' + that
|
|
|
+ .totalPrice
|
|
|
+ });
|
|
|
+
|
|
|
+ },
|
|
|
+ "fail": function(res) {
|
|
|
+ that.$refs.uToast.show({
|
|
|
+ type: 'error',
|
|
|
+ message: '支付失败!'
|
|
|
+ })
|
|
|
+ setTimeout(() => {
|
|
|
+ uni.redirectTo({
|
|
|
+ url: '/pages/order/myOrder/myOrder?type=1'
|
|
|
+ });
|
|
|
+ }, 1000)
|
|
|
+ console.log('调用支付接口fail', res)
|
|
|
+ },
|
|
|
+ "complete": function(res) {
|
|
|
+ console.log('调用支付接口完成', res)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ complete: () => {
|
|
|
+ this.load = false
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|