|
@@ -1,6 +1,8 @@
|
|
|
// pages/groupmeallist/submitOrder/submitOrder.js
|
|
|
import storeGoods from '../../../api/storeGoods'
|
|
|
const cache = require('../../../utils/cache.js');
|
|
|
+
|
|
|
+const user = require('../../../utils/user.js');
|
|
|
import base from '../../../utils/base'
|
|
|
Page({
|
|
|
|
|
@@ -12,10 +14,18 @@ Page({
|
|
|
store: {},
|
|
|
phone: '',
|
|
|
storeWay: '',
|
|
|
- addressvaule:'',
|
|
|
- addressId:'',
|
|
|
+ addressvaule: '',
|
|
|
+ addressId: '',
|
|
|
+ coupon: '',
|
|
|
+ couponSn: '',
|
|
|
+ hallFood: '',
|
|
|
+ invoiceValue: '',
|
|
|
+ invoiceId: '',
|
|
|
+ hidden: true,
|
|
|
+ inputValue: '',
|
|
|
+ remark: '',
|
|
|
+
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
showAllSku: false,
|
|
@@ -36,18 +46,87 @@ Page({
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
+ let coupon = options.coupon
|
|
|
+
|
|
|
+
|
|
|
+ if (coupon != null) {
|
|
|
+ let jsoncoupon = JSON.parse(coupon)
|
|
|
+ this.setData({
|
|
|
+ coupon: jsoncoupon,
|
|
|
+ couponSn: jsoncoupon.sn
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ let invoiceValue = options.invoiceValue
|
|
|
+ let invoiceId = options.invoiceId
|
|
|
+ if (invoiceValue != null && invoiceId != null) {
|
|
|
+ this.setData({
|
|
|
+ invoiceValue: invoiceValue,
|
|
|
+ invoiceId: invoiceId
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
let addressvaule = options.addressvalue
|
|
|
let addressId = options.addressId
|
|
|
- if(addressvaule !=null && addressId!=null ){
|
|
|
+ if (addressvaule != null && addressId != null) {
|
|
|
+ let address = {
|
|
|
+ addressvaule: addressvaule,
|
|
|
+ addressId: addressId
|
|
|
+ }
|
|
|
+ // 设置地址缓存
|
|
|
+ cache.setaddress(address)
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ addressvaule: addressvaule,
|
|
|
+ addressId: addressId
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 取消
|
|
|
+ */
|
|
|
+ cancel: function () {
|
|
|
this.setData({
|
|
|
- addressvaule:addressvaule,
|
|
|
- addressId:addressId
|
|
|
+ hidden: true,
|
|
|
+ inputValue: '',
|
|
|
+ remark: '',
|
|
|
+ });
|
|
|
+ },
|
|
|
|
|
|
- })
|
|
|
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 提交
|
|
|
+ */
|
|
|
+ confirm: function (e) {
|
|
|
+ let inputValue = e.detail.value
|
|
|
+ this.setData({
|
|
|
+ hidden: true,
|
|
|
+ inputValue: inputValue,
|
|
|
+ remark: inputValue,
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 备注
|
|
|
+ */
|
|
|
+ getReason: function (e) {
|
|
|
+ this.setData({
|
|
|
+ inputValue: e.detail.value
|
|
|
+ })
|
|
|
+ },
|
|
|
|
|
|
+ remarkShow() {
|
|
|
+ this.setData({
|
|
|
+ hidden: false,
|
|
|
+ // inputValue: '',
|
|
|
+ // remark: '',
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -56,20 +135,148 @@ Page({
|
|
|
onReady: function () {
|
|
|
|
|
|
},
|
|
|
+ listenInput(e) {
|
|
|
+ this.setData({
|
|
|
+ phone: e.detail.value
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
+ // 提交订单
|
|
|
+ submitOrder() {
|
|
|
+ console.log("进入创建订单方法")
|
|
|
+ let parms = {}
|
|
|
+ if (!this.data.isValid) {
|
|
|
+ app.showToast("购物车无商品")
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // parms={
|
|
|
+ // mobile:cache.getMobile(),
|
|
|
+ // storeId:cache.getStoreId(),
|
|
|
+ // couponSn:this.data.couponSn,
|
|
|
+ // dinnerType:this.data.storeWay,
|
|
|
+ // addressId:this.data.addressId,
|
|
|
+ // invoiceId:this.data.invoiceId,
|
|
|
+ // phone:this.data.phone,
|
|
|
+ // remark:this.data.remark
|
|
|
+ // }
|
|
|
+ storeGoods.creatOrder({
|
|
|
+ mobile: cache.getMobile(),
|
|
|
+ storeId: cache.getStoreId(),
|
|
|
+ couponSn: this.data.couponSn,
|
|
|
+ dinnerType: this.data.storeWay,
|
|
|
+ addressId: this.data.addressId,
|
|
|
+ invoiceId: this.data.invoiceId,
|
|
|
+ phone: this.data.phone,
|
|
|
+ remark: this.data.remark
|
|
|
+ }).then(res => {
|
|
|
+ if (res.code == 200 && res.data.state != -2) {
|
|
|
+ // 唤起收银台
|
|
|
+ this.goToPay(res.data)
|
|
|
+ } else if (res.data.state != -2) {
|
|
|
+ wx.redirectTo({
|
|
|
+ url: '/pages/userOrderList/userOrderList',
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
+ }).catch(_ => {
|
|
|
+ // this.setData({
|
|
|
+ // isShowPannel: true
|
|
|
+ // })
|
|
|
+
|
|
|
+ this.tapSex()
|
|
|
+ console.log(_)
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
+ tapSex:function(res){
|
|
|
+ var that = this
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '订单创建失败,确认之后返回购物栏',
|
|
|
+ showCancel: false,
|
|
|
+ confirmText:'确认',
|
|
|
+ success(res){
|
|
|
+ if(res.confirm){
|
|
|
+ that.goToStoreGoods()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ goToPay(order) {
|
|
|
+ const storeInfo = cache.getCurrStore()
|
|
|
+
|
|
|
+ console.log(user.getUserInfo().openid,)
|
|
|
+ console.log(storeInfo)
|
|
|
+ storeGoods.getPayParams({
|
|
|
+ orderSn: order.orderSn,
|
|
|
+ payCode: storeInfo.payCode,
|
|
|
+ openId: user.getUserInfo().openid,
|
|
|
+ isOrderPayment: true,
|
|
|
+ orderInfoPath: "../orderDetail/orderDetail?sn=" + order.orderSn,
|
|
|
+ productDetailPath: "../storeGoods/storeGoods",
|
|
|
+ }).then(res => {
|
|
|
+ if (res.code == 200) {
|
|
|
+ this.rousePayment(res.data, order)
|
|
|
+ }
|
|
|
+ }).catch(_ => {
|
|
|
+ console.log(_)
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
+ rousePayment(payParam, order) {
|
|
|
+ wx.requestOrderPayment({
|
|
|
+ timeStamp: payParam.wxPrePay.timeStamp,
|
|
|
+ package: payParam.wxPrePay.pack,
|
|
|
+ nonceStr: payParam.wxPrePay.nonceStr,
|
|
|
+ signType: payParam.wxPrePay.signType,
|
|
|
+ paySign: payParam.wxPrePay.paySign,
|
|
|
+ orderInfo:payParam.orderInfo,
|
|
|
+ success: function (res) {
|
|
|
+ //支付成功,跳转领取成功页面
|
|
|
+ console.log("支付成功,跳到订单详情页面")
|
|
|
+ OrderApi.getPayStatus(order.orderSn);
|
|
|
+ app.showToast("支付成功")
|
|
|
+ wx.redirectTo({
|
|
|
+ url: '../orderDetail/orderDetail?sn=' + order.orderSn,
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail: function (res) {
|
|
|
+ app.showToast("支付失败")
|
|
|
+ wx.redirectTo({
|
|
|
+ url: '../orderDetail/orderDetail?sn=' + order.orderSn,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面显示
|
|
|
*/
|
|
|
onShow: function () {
|
|
|
let store = cache.getCurrStore();
|
|
|
- let storeWay = cache.getStoreWay()
|
|
|
-
|
|
|
console.log(store)
|
|
|
- console.log(storeWay)
|
|
|
+ let storeWay = cache.getStoreWay();
|
|
|
+
|
|
|
+ let address = cache.getaddress();
|
|
|
+ if (address != null) {
|
|
|
+ this.setData({
|
|
|
+ addressvaule: address.addressvaule,
|
|
|
+ addressId: address.addressId,
|
|
|
+ })
|
|
|
+ }
|
|
|
if (store != null) {
|
|
|
this.setData({
|
|
|
store: store,
|
|
|
- storeWay: storeWay
|
|
|
+ storeWay: storeWay,
|
|
|
+ hallFood: store.hallFood
|
|
|
})
|
|
|
|
|
|
}
|
|
@@ -79,7 +286,13 @@ Page({
|
|
|
|
|
|
|
|
|
},
|
|
|
+ //发票列表
|
|
|
+ gotoinvoice() {
|
|
|
+ wx.redirectTo({
|
|
|
+ url: '../invoicesList/invoicesList?way=' + 'order',
|
|
|
+ })
|
|
|
|
|
|
+ },
|
|
|
// 自动获取手机号
|
|
|
|
|
|
getPhone() {
|
|
@@ -118,13 +331,19 @@ Page({
|
|
|
console.log(_)
|
|
|
})
|
|
|
},
|
|
|
+ //选择卡券
|
|
|
+ gotoselectcoupon() {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '../couponlist/couponlist',
|
|
|
+ })
|
|
|
|
|
|
+ },
|
|
|
|
|
|
/**
|
|
|
* 加载购物车数据
|
|
|
*/
|
|
|
loadCartData() {
|
|
|
- storeGoods.getCartData(cache.getStoreId(), cache.getMobile(), null, null).then(res => {
|
|
|
+ storeGoods.getCartData(cache.getStoreId(), cache.getMobile(), null, this.data.couponSn, ).then(res => {
|
|
|
if (res.code == 200) {
|
|
|
this.cartDataMapToView(res.data)
|
|
|
}
|