|
@@ -15,19 +15,25 @@ Page({
|
|
bottomNavHeight: 0,
|
|
bottomNavHeight: 0,
|
|
contentHeight: 0,
|
|
contentHeight: 0,
|
|
|
|
|
|
- imageUrls: ['https://img95.699pic.com/photo/60072/5330.jpg_wh860.jpg',
|
|
|
|
- 'https://c-ssl.dtstatic.com/uploads/blog/201409/27/20140927230814_4QfVC.thumb.1000_0.jpeg',
|
|
|
|
- 'https://ts1.cn.mm.bing.net/th/id/R-C.37f4077f8eaca918401b84b4ee23af7c?rik=7HYWC88a9q4sZw&riu=http%3a%2f%2fpic.616pic.com%2fphotoone%2f00%2f06%2f03%2f618e27ad7ce8e1124.jpg&ehk=jkc6iZWAg%2bAEjAk6%2br0VAAy1lfffqslT6n%2fMWl293Yc%3d&risl=&pid=ImgRaw&r=0'
|
|
|
|
- ],
|
|
|
|
|
|
+
|
|
gid: null, //商品id
|
|
gid: null, //商品id
|
|
good: null, //商品详情
|
|
good: null, //商品详情
|
|
spec: null, //商品规格
|
|
spec: null, //商品规格
|
|
checkSpec: null, //选中的规格
|
|
checkSpec: null, //选中的规格
|
|
totalPrice: 0, //订单总价
|
|
totalPrice: 0, //订单总价
|
|
- specBox: false, //规格弹框
|
|
|
|
address: null, //收货地址
|
|
address: null, //收货地址
|
|
tradeNo: null, //订单编号
|
|
tradeNo: null, //订单编号
|
|
order: null, //当前订单-parse
|
|
order: null, //当前订单-parse
|
|
|
|
+ distributeType: 'delivery', //配送方式-默认物流配送
|
|
|
|
+ count: 1, //单独购买商品总数
|
|
|
|
+ specMap: {}, //save到订单的数据
|
|
|
|
+ specBox: false, //规格弹框
|
|
|
|
+ moreBox: false, //选择多款弹框
|
|
|
|
+ listBox: false, //多款列表弹框
|
|
|
|
+ specGoodList: [], //选择的多款商品-多款
|
|
|
|
+ checkSpec_more: null, //选中的规格-多款
|
|
|
|
+ count_more: 1, //购买商品总数-多款
|
|
|
|
+ totalPrice_more: 0, //订单总价-多款
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -63,38 +69,52 @@ Page({
|
|
gid
|
|
gid
|
|
} = this.data
|
|
} = this.data
|
|
let query = new Parse.Query('ShopGoods')
|
|
let query = new Parse.Query('ShopGoods')
|
|
|
|
+ query.include('shopStore')
|
|
let d = await query.get(gid)
|
|
let d = await query.get(gid)
|
|
let good = d?.toJSON()
|
|
let good = d?.toJSON()
|
|
- console.log(good)
|
|
|
|
- let spec = good?.specMap?.specList.map(item => {
|
|
|
|
- let price = good.specMap[item][0].price
|
|
|
|
- let subName = price || good.price
|
|
|
|
- let obj = {
|
|
|
|
- name: item,
|
|
|
|
- subname: `售价¥${subName}`,
|
|
|
|
- color: 'gray',
|
|
|
|
- price: subName
|
|
|
|
|
|
+ if (!good?.images || good?.images?.length <= 0) good.images = [good.image || 'https://file-cloud.fmode.cn/EbxZUK5lBI/20250321/vdq1j1110711455.jpg']
|
|
|
|
+ if (!good?.specMap || !good?.specMap?.specList || good?.specMap?.specList?.length <= 0) {
|
|
|
|
+ good.specMap = {
|
|
|
|
+ specList: [good?.name || '暂无规格']
|
|
}
|
|
}
|
|
- return obj
|
|
|
|
- })
|
|
|
|
|
|
+ good.specMap[good?.name || '暂无规格'] = [{
|
|
|
|
+ price: good?.price || 0,
|
|
|
|
+ }]
|
|
|
|
+ }
|
|
|
|
+ console.log(good)
|
|
|
|
+ let spec = good?.specMap?.specList
|
|
let checkSpec = {}
|
|
let checkSpec = {}
|
|
- if (spec?.length) {
|
|
|
|
- checkSpec = spec[0]
|
|
|
|
- spec[0].color = 'red'
|
|
|
|
|
|
+ if (spec && spec?.length > 0) {
|
|
|
|
+ checkSpec = good?.specMap[spec[0]][0]
|
|
|
|
+ checkSpec.title = spec[0]
|
|
}
|
|
}
|
|
- let totalPrice = checkSpec.price || good.price
|
|
|
|
|
|
+ let totalPrice = checkSpec?.price || good?.price
|
|
|
|
+ console.log(spec, checkSpec)
|
|
this.setData({
|
|
this.setData({
|
|
good,
|
|
good,
|
|
|
|
+ store: good.shopStore,
|
|
spec,
|
|
spec,
|
|
checkSpec,
|
|
checkSpec,
|
|
totalPrice
|
|
totalPrice
|
|
})
|
|
})
|
|
|
|
+ this.getTotalPrice()
|
|
},
|
|
},
|
|
|
|
+ /**切换配送方式 */
|
|
|
|
+ chickDistributeType(e) {
|
|
|
|
+ let {
|
|
|
|
+ type
|
|
|
|
+ } = e.currentTarget.dataset
|
|
|
|
+ this.setData({
|
|
|
|
+ distributeType: type
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
/** 打开规格弹框*/
|
|
/** 打开规格弹框*/
|
|
openSpec() {
|
|
openSpec() {
|
|
- let {spec} = this.data
|
|
|
|
- console.log(spec,'‘hhh')
|
|
|
|
- if(spec?.length<=0)return
|
|
|
|
|
|
+ let {
|
|
|
|
+ spec
|
|
|
|
+ } = this.data
|
|
|
|
+ if (spec?.length <= 0) return
|
|
this.setData({
|
|
this.setData({
|
|
specBox: true
|
|
specBox: true
|
|
})
|
|
})
|
|
@@ -108,38 +128,247 @@ Page({
|
|
/**选择规格 */
|
|
/**选择规格 */
|
|
getCheckSpec(e) {
|
|
getCheckSpec(e) {
|
|
let {
|
|
let {
|
|
|
|
+ good,
|
|
spec,
|
|
spec,
|
|
checkSpec,
|
|
checkSpec,
|
|
- totalPrice
|
|
|
|
|
|
+ totalPrice,
|
|
} = this.data
|
|
} = this.data
|
|
- checkSpec = e.detail
|
|
|
|
- spec = spec.map(item => {
|
|
|
|
- item.color = 'gray'
|
|
|
|
- if (item.name == checkSpec.name) {
|
|
|
|
- item.color = 'red'
|
|
|
|
- totalPrice = item.price
|
|
|
|
- }
|
|
|
|
- return item
|
|
|
|
|
|
+ let {
|
|
|
|
+ title
|
|
|
|
+ } = e.currentTarget.dataset
|
|
|
|
+ checkSpec = good?.specMap[title][0]
|
|
|
|
+ checkSpec.title = title
|
|
|
|
+ totalPrice = checkSpec?.price || good?.price
|
|
|
|
+ console.log(spec, checkSpec)
|
|
|
|
+ this.setData({
|
|
|
|
+ spec,
|
|
|
|
+ checkSpec,
|
|
|
|
+ totalPrice,
|
|
|
|
+
|
|
})
|
|
})
|
|
|
|
+ this.getTotalPrice()
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ /**单个物品-步进器改变 */
|
|
|
|
+ changeCount(e) {
|
|
|
|
+ this.setData({
|
|
|
|
+ count: e.detail
|
|
|
|
+ })
|
|
|
|
+ this.getTotalPrice()
|
|
|
|
+ },
|
|
|
|
+ /**计算单个物品总价/获取specMap */
|
|
|
|
+ getTotalPrice() {
|
|
|
|
+ let {
|
|
|
|
+ good,
|
|
|
|
+ count,
|
|
|
|
+ checkSpec
|
|
|
|
+ } = this.data
|
|
|
|
+ let specMap = {}
|
|
|
|
+ specMap[good.objectId] = {
|
|
|
|
+ count,
|
|
|
|
+ price: checkSpec.price,
|
|
|
|
+ spec: checkSpec?.title || ''
|
|
|
|
+ }
|
|
|
|
+ let totalPrice = parseFloat((count * checkSpec.price).toFixed(2))
|
|
|
|
+ console.log(specMap, totalPrice)
|
|
this.setData({
|
|
this.setData({
|
|
|
|
+ totalPrice,
|
|
|
|
+ specMap
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /** 打开多款弹框*/
|
|
|
|
+ openMoreBox() {
|
|
|
|
+ let {
|
|
spec,
|
|
spec,
|
|
checkSpec,
|
|
checkSpec,
|
|
- totalPrice
|
|
|
|
|
|
+ good
|
|
|
|
+ } = this.data
|
|
|
|
+ console.log(spec, checkSpec, good)
|
|
|
|
+ let price = good.specMap[spec[0]][0].price || good.price
|
|
|
|
+ this.setData({
|
|
|
|
+ moreBox: true,
|
|
|
|
+ count_more: 1,
|
|
|
|
+ checkSpec_more: {
|
|
|
|
+ price: price,
|
|
|
|
+ title: spec[0],
|
|
|
|
+ totalPrice: price
|
|
|
|
+ }
|
|
})
|
|
})
|
|
|
|
+ console.log(spec, checkSpec, good)
|
|
|
|
+
|
|
},
|
|
},
|
|
- /** 跳转*/
|
|
|
|
- tourl(e) {
|
|
|
|
- const url = e.currentTarget.dataset.url
|
|
|
|
- wx.navigateTo({
|
|
|
|
- url: `${url}` // 目标页面的路径
|
|
|
|
- });
|
|
|
|
|
|
+ /**关闭多款弹框 */
|
|
|
|
+ closeMoreBox() {
|
|
|
|
+ this.setData({
|
|
|
|
+ moreBox: false
|
|
|
|
+ })
|
|
},
|
|
},
|
|
|
|
+ /**多款-步进器改变 */
|
|
|
|
+ changeCount_more(e) {
|
|
|
|
+ this.setData({
|
|
|
|
+ count_more: e.detail
|
|
|
|
+ })
|
|
|
|
+ this.getCurrentSpec()
|
|
|
|
+ },
|
|
|
|
+ /**选择规格-多款 */
|
|
|
|
+ getCheckSpec_more(e) {
|
|
|
|
+ let {
|
|
|
|
+ good,
|
|
|
|
+ spec,
|
|
|
|
+ checkSpec_more,
|
|
|
|
+ } = this.data
|
|
|
|
+ let {
|
|
|
|
+ title
|
|
|
|
+ } = e.currentTarget.dataset
|
|
|
|
+ checkSpec_more = good?.specMap[title][0]
|
|
|
|
+ checkSpec_more.title = title
|
|
|
|
+ console.log(spec, checkSpec_more)
|
|
|
|
+ this.setData({
|
|
|
|
+ checkSpec_more,
|
|
|
|
+ })
|
|
|
|
+ this.getCurrentSpec()
|
|
|
|
+ },
|
|
|
|
+ /**计算当前款式价格/specMap - 多款 */
|
|
|
|
+ getCurrentSpec() {
|
|
|
|
+ let {
|
|
|
|
+ checkSpec_more,
|
|
|
|
+ count_more
|
|
|
|
+ } = this.data
|
|
|
|
+ let totalPrice = (checkSpec_more.price * count_more || 0).toFixed(2)
|
|
|
|
+ checkSpec_more.totalPrice = totalPrice
|
|
|
|
+ console.log(checkSpec_more, count_more)
|
|
|
|
+ this.setData({
|
|
|
|
+ checkSpec_more
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ /**确定当前款 */
|
|
|
|
+ confirmCurrent() {
|
|
|
|
+ let {
|
|
|
|
+ specGoodList,
|
|
|
|
+ count_more,
|
|
|
|
+ checkSpec_more,
|
|
|
|
+ } = this.data
|
|
|
|
+ let index = specGoodList?.findIndex(item => item.spec == checkSpec_more.title)
|
|
|
|
+ if (index < 0) {
|
|
|
|
+ specGoodList.push({
|
|
|
|
+ count: count_more,
|
|
|
|
+ price: checkSpec_more.price,
|
|
|
|
+ spec: checkSpec_more.title,
|
|
|
|
+ checked: true
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ specGoodList[index] = {
|
|
|
|
+ count: count_more,
|
|
|
|
+ price: checkSpec_more.price,
|
|
|
|
+ spec: checkSpec_more.title,
|
|
|
|
+ checked: true
|
|
|
|
+ }
|
|
|
|
+ wx.showToast({
|
|
|
|
+ title: `已勾选并修改 ${checkSpec_more.title} 款式数量为${count_more}`,
|
|
|
|
+ icon: 'none'
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ this.setData({
|
|
|
|
+ specGoodList
|
|
|
|
+ })
|
|
|
|
+ this.getTotalPrice_more()
|
|
|
|
+ this.closeMoreBox()
|
|
|
|
+ this.openListBox()
|
|
|
|
+ },
|
|
|
|
+ /**计算物品总价 - 多款*/
|
|
|
|
+ getTotalPrice_more() {
|
|
|
|
+ let {
|
|
|
|
+ good,
|
|
|
|
+ specGoodList,
|
|
|
|
+ totalPrice_more,
|
|
|
|
+ } = this.data
|
|
|
|
+ totalPrice_more = 0
|
|
|
|
+ let list = specGoodList.filter(item => item.checked)
|
|
|
|
+ for (let i in list) {
|
|
|
|
+ let item = list[i]
|
|
|
|
+ if (item.checked) {
|
|
|
|
+ totalPrice_more = parseFloat((totalPrice_more + (item.price * item.count)).toFixed(2))
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ let specMap = {}
|
|
|
|
+ specMap[good.objectId] = {
|
|
|
|
+ price: totalPrice_more || 0,
|
|
|
|
+ list: list || []
|
|
|
|
+ }
|
|
|
|
+ console.log(specMap, specGoodList, totalPrice_more)
|
|
|
|
+ this.setData({
|
|
|
|
+ totalPrice_more: parseFloat(totalPrice_more),
|
|
|
|
+ specMap,
|
|
|
|
+ specGoodList
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ /**列表-多款-步进器改变 */
|
|
|
|
+ changeLMCount(e) {
|
|
|
|
+ let {
|
|
|
|
+ specGoodList
|
|
|
|
+ } = this.data
|
|
|
|
+ let {
|
|
|
|
+ index
|
|
|
|
+ } = e.currentTarget.dataset
|
|
|
|
+ specGoodList[index].count = parseInt(e.detail || 1)
|
|
|
|
+ this.setData({
|
|
|
|
+ specGoodList
|
|
|
|
+ })
|
|
|
|
+ this.getTotalPrice_more()
|
|
|
|
+ },
|
|
|
|
+ /**列表-是否选中 */
|
|
|
|
+ changeChecked(e) {
|
|
|
|
+ console.log(e)
|
|
|
|
+ let {
|
|
|
|
+ specGoodList
|
|
|
|
+ } = this.data
|
|
|
|
+ let {
|
|
|
|
+ index
|
|
|
|
+ } = e.currentTarget.dataset
|
|
|
|
+ specGoodList[index].checked = e.detail
|
|
|
|
+ this.setData({
|
|
|
|
+ specGoodList
|
|
|
|
+ })
|
|
|
|
+ this.getTotalPrice_more()
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**多款款式弹框-去结算 */
|
|
|
|
+ settlement() {
|
|
|
|
+ this.closeMoreBox()
|
|
|
|
+ this.openListBox()
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /** 打开多款列表弹框*/
|
|
|
|
+ openListBox() {
|
|
|
|
+ this.setData({
|
|
|
|
+ listBox: true,
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ /**关闭多款列表弹框 */
|
|
|
|
+ closeListBox() {
|
|
|
|
+ this.setData({
|
|
|
|
+ listBox: false
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
/** 判断是否可创建订单*/
|
|
/** 判断是否可创建订单*/
|
|
judgeOrder() {
|
|
judgeOrder() {
|
|
let {
|
|
let {
|
|
- address
|
|
|
|
|
|
+ address,
|
|
|
|
+ distributeType
|
|
} = this.data
|
|
} = this.data
|
|
- if (!address?.objectId) {
|
|
|
|
|
|
+ if (distributeType == 'delivery' && !address?.objectId) {
|
|
wx.showToast({
|
|
wx.showToast({
|
|
title: '请确认收货地址',
|
|
title: '请确认收货地址',
|
|
icon: 'none',
|
|
icon: 'none',
|
|
@@ -148,29 +377,30 @@ Page({
|
|
}
|
|
}
|
|
return true
|
|
return true
|
|
},
|
|
},
|
|
- /**创建订单 */
|
|
|
|
|
|
+ /** 判断是否可创建订单-多款*/
|
|
|
|
+ judgeOrder_more() {
|
|
|
|
+ let addCheck = this.judgeOrder()
|
|
|
|
+ let {specGoodList} = this.data
|
|
|
|
+ let index = specGoodList.findIndex(item=>item.checked)
|
|
|
|
+ if(addCheck&&index!=-1) return true
|
|
|
|
+ return false
|
|
|
|
+ },
|
|
|
|
+ /**创建订单-单个商品 */
|
|
async submitOrder() {
|
|
async submitOrder() {
|
|
|
|
+ this.getTotalPrice()
|
|
let isPass = this.judgeOrder()
|
|
let isPass = this.judgeOrder()
|
|
if (!isPass) return
|
|
if (!isPass) return
|
|
let {
|
|
let {
|
|
good,
|
|
good,
|
|
totalPrice,
|
|
totalPrice,
|
|
- checkSpec,
|
|
|
|
address,
|
|
address,
|
|
order,
|
|
order,
|
|
- tradeNo
|
|
|
|
|
|
+ tradeNo,
|
|
|
|
+ specMap,
|
|
|
|
+ distributeType
|
|
} = this.data
|
|
} = this.data
|
|
let o = order
|
|
let o = order
|
|
if (!order?.id) {
|
|
if (!order?.id) {
|
|
- let now = new Date()
|
|
|
|
- tradeNo = "C" +
|
|
|
|
- String(now.getFullYear()) +
|
|
|
|
- (now.getMonth() + 1) +
|
|
|
|
- now.getDate() +
|
|
|
|
- now.getHours() +
|
|
|
|
- now.getMinutes() +
|
|
|
|
- now.getSeconds() +
|
|
|
|
- Math.random().toString().slice(-6);
|
|
|
|
let Order = Parse.Object.extend("Order");
|
|
let Order = Parse.Object.extend("Order");
|
|
o = new Order()
|
|
o = new Order()
|
|
o.set("company", {
|
|
o.set("company", {
|
|
@@ -178,12 +408,16 @@ Page({
|
|
className: 'Company',
|
|
className: 'Company',
|
|
objectId: company
|
|
objectId: company
|
|
})
|
|
})
|
|
|
|
+ o.set("store", {
|
|
|
|
+ __type: 'Pointer',
|
|
|
|
+ className: 'ShopStore',
|
|
|
|
+ objectId: good?.shopStore?.objectId
|
|
|
|
+ })
|
|
o.set("user", {
|
|
o.set("user", {
|
|
__type: 'Pointer',
|
|
__type: 'Pointer',
|
|
className: '_User',
|
|
className: '_User',
|
|
objectId: uid
|
|
objectId: uid
|
|
})
|
|
})
|
|
- o.set("orderNum", tradeNo);
|
|
|
|
o.set('status', '100') //待支付
|
|
o.set('status', '100') //待支付
|
|
o.set('type', 'scenery')
|
|
o.set('type', 'scenery')
|
|
o.set("targetObject", [{
|
|
o.set("targetObject", [{
|
|
@@ -192,35 +426,132 @@ Page({
|
|
"objectId": good?.objectId
|
|
"objectId": good?.objectId
|
|
}])
|
|
}])
|
|
}
|
|
}
|
|
|
|
+ let now = new Date()
|
|
|
|
+ tradeNo = "C" +
|
|
|
|
+ String(now.getFullYear()) +
|
|
|
|
+ (now.getMonth() + 1) +
|
|
|
|
+ now.getDate() +
|
|
|
|
+ now.getHours() +
|
|
|
|
+ now.getMinutes() +
|
|
|
|
+ now.getSeconds() +
|
|
|
|
+ Math.random().toString().slice(-6);
|
|
|
|
+ o.set("orderNum", tradeNo);
|
|
o.set("totalPrice", totalPrice || 0);
|
|
o.set("totalPrice", totalPrice || 0);
|
|
- o.set("address", {
|
|
|
|
- __type: 'Pointer',
|
|
|
|
- className: 'ShopAddress',
|
|
|
|
- objectId: address?.objectId
|
|
|
|
- });
|
|
|
|
- o.set("info", {
|
|
|
|
- name: address?.name,
|
|
|
|
- mobile: address?.mobile,
|
|
|
|
- address: address?.full_region + address?.address
|
|
|
|
- });
|
|
|
|
- let specMap = {}
|
|
|
|
- specMap[good?.objectId] = {
|
|
|
|
- count: 1,
|
|
|
|
- price: good.price,
|
|
|
|
- spec: checkSpec.name
|
|
|
|
|
|
+ o.set("distributeType", distributeType || 'verify');
|
|
|
|
+ if (distributeType == 'verify') {
|
|
|
|
+ o.set("info", {});
|
|
|
|
+ } else {
|
|
|
|
+ o.set("address", {
|
|
|
|
+ __type: 'Pointer',
|
|
|
|
+ className: 'ShopAddress',
|
|
|
|
+ objectId: address?.objectId
|
|
|
|
+ });
|
|
|
|
+ o.set("info", {
|
|
|
|
+ name: address?.name,
|
|
|
|
+ mobile: address?.mobile,
|
|
|
|
+ address: address?.full_region + address?.address
|
|
|
|
+ });
|
|
}
|
|
}
|
|
o.set("specMap", specMap);
|
|
o.set("specMap", specMap);
|
|
try {
|
|
try {
|
|
- // order = await o.save()
|
|
|
|
|
|
+ order = await o.save()
|
|
this.setData({
|
|
this.setData({
|
|
tradeNo,
|
|
tradeNo,
|
|
- order:o,
|
|
|
|
|
|
+ order: o,
|
|
showPay: true,
|
|
showPay: true,
|
|
|
|
+ showPay_more:false,
|
|
|
|
+ })
|
|
|
|
+ wx.showToast({
|
|
|
|
+ title: '已创建订单',
|
|
|
|
+ icon: 'none'
|
|
|
|
+ })
|
|
|
|
+ } catch (error) {
|
|
|
|
+ wx.showToast({
|
|
|
|
+ title: '出错了请检查后重试',
|
|
|
|
+ icon: 'error'
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ /**创建订单-多款规格 */
|
|
|
|
+ async submitOrder_more() {
|
|
|
|
+ this.getTotalPrice_more()
|
|
|
|
+ let isPass = this.judgeOrder_more()
|
|
|
|
+ if (!isPass) return
|
|
|
|
+ let {
|
|
|
|
+ good,
|
|
|
|
+ totalPrice_more,
|
|
|
|
+ address,
|
|
|
|
+ order,
|
|
|
|
+ tradeNo,
|
|
|
|
+ specMap,
|
|
|
|
+ distributeType
|
|
|
|
+ } = this.data
|
|
|
|
+ let o = order
|
|
|
|
+ if (!order?.id) {
|
|
|
|
+ let Order = Parse.Object.extend("Order");
|
|
|
|
+ o = new Order()
|
|
|
|
+ o.set("company", {
|
|
|
|
+ __type: 'Pointer',
|
|
|
|
+ className: 'Company',
|
|
|
|
+ objectId: company
|
|
|
|
+ })
|
|
|
|
+ o.set("store", {
|
|
|
|
+ __type: 'Pointer',
|
|
|
|
+ className: 'ShopStore',
|
|
|
|
+ objectId: good?.shopStore?.objectId
|
|
|
|
+ })
|
|
|
|
+ o.set("user", {
|
|
|
|
+ __type: 'Pointer',
|
|
|
|
+ className: '_User',
|
|
|
|
+ objectId: uid
|
|
|
|
+ })
|
|
|
|
+ o.set('status', '100') //待支付
|
|
|
|
+ o.set('type', 'scenery')
|
|
|
|
+ o.set("targetObject", [{
|
|
|
|
+ "__type": "Pointer",
|
|
|
|
+ "className": "ShopGoods",
|
|
|
|
+ "objectId": good?.objectId
|
|
|
|
+ }])
|
|
|
|
+ }
|
|
|
|
+ let now = new Date()
|
|
|
|
+ tradeNo = "C" +
|
|
|
|
+ String(now.getFullYear()) +
|
|
|
|
+ (now.getMonth() + 1) +
|
|
|
|
+ now.getDate() +
|
|
|
|
+ now.getHours() +
|
|
|
|
+ now.getMinutes() +
|
|
|
|
+ now.getSeconds() +
|
|
|
|
+ Math.random().toString().slice(-6);
|
|
|
|
+ o.set("orderNum", tradeNo);
|
|
|
|
+ o.set("totalPrice", totalPrice_more || 0);
|
|
|
|
+ o.set("distributeType", distributeType || 'verify');
|
|
|
|
+ if (distributeType == 'verify') {
|
|
|
|
+ o.set("info", {});
|
|
|
|
+ } else {
|
|
|
|
+ o.set("address", {
|
|
|
|
+ __type: 'Pointer',
|
|
|
|
+ className: 'ShopAddress',
|
|
|
|
+ objectId: address?.objectId
|
|
|
|
+ });
|
|
|
|
+ o.set("info", {
|
|
|
|
+ name: address?.name,
|
|
|
|
+ mobile: address?.mobile,
|
|
|
|
+ address: address?.full_region + address?.address
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ o.set("specMap", specMap);
|
|
|
|
+ try {
|
|
|
|
+ order = await o.save()
|
|
|
|
+ this.setData({
|
|
|
|
+ tradeNo,
|
|
|
|
+ order: o,
|
|
|
|
+ showPay: false,
|
|
|
|
+ showPay_more:true
|
|
|
|
+ })
|
|
|
|
+ wx.showToast({
|
|
|
|
+ title: '已创建订单',
|
|
|
|
+ icon: 'none'
|
|
})
|
|
})
|
|
- // wx.showToast({
|
|
|
|
- // title: '已创建订单',
|
|
|
|
- // icon: 'none'
|
|
|
|
- // })
|
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
wx.showToast({
|
|
wx.showToast({
|
|
title: '出错了请检查后重试',
|
|
title: '出错了请检查后重试',
|
|
@@ -241,6 +572,7 @@ Page({
|
|
title: '加载中',
|
|
title: '加载中',
|
|
})
|
|
})
|
|
order.set('status', '200')
|
|
order.set('status', '200')
|
|
|
|
+ order.set('payTime',new Date())
|
|
order.set('payType', 'wx')
|
|
order.set('payType', 'wx')
|
|
order.set('isPay', true)
|
|
order.set('isPay', true)
|
|
try {
|
|
try {
|
|
@@ -265,6 +597,13 @@ Page({
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ /** 跳转*/
|
|
|
|
+ tourl(e) {
|
|
|
|
+ const url = e.currentTarget.dataset.url
|
|
|
|
+ wx.navigateTo({
|
|
|
|
+ url: `${url}` // 目标页面的路径
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
* 生命周期函数--监听页面初次渲染完成
|