|
@@ -1,5 +1,6 @@
|
|
// pages/order/confirmOreder/confirmOreder.js
|
|
// pages/order/confirmOreder/confirmOreder.js
|
|
-const app=getApp();
|
|
|
|
|
|
+const app = getApp();
|
|
|
|
+const addr = require('../../my/address/addSite/addSite.js');
|
|
Page({
|
|
Page({
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -9,59 +10,101 @@ Page({
|
|
currentList: [{
|
|
currentList: [{
|
|
tit: '塑封包膜',
|
|
tit: '塑封包膜',
|
|
num: "30",
|
|
num: "30",
|
|
- id:1
|
|
|
|
|
|
+ id: 1
|
|
}, {
|
|
}, {
|
|
tit: '绒面鞋补色',
|
|
tit: '绒面鞋补色',
|
|
num: "20",
|
|
num: "20",
|
|
- id:2
|
|
|
|
|
|
+ id: 2
|
|
}, {
|
|
}, {
|
|
tit: '防水处理',
|
|
tit: '防水处理',
|
|
num: "20",
|
|
num: "20",
|
|
- id:3
|
|
|
|
|
|
+ id: 3
|
|
}, {
|
|
}, {
|
|
tit: '防水处理',
|
|
tit: '防水处理',
|
|
num: "10",
|
|
num: "10",
|
|
- id:4
|
|
|
|
|
|
+ id: 4
|
|
}],
|
|
}],
|
|
- mode:true,
|
|
|
|
- checked:false,
|
|
|
|
- show1:false,
|
|
|
|
- show2:false,
|
|
|
|
- code:""
|
|
|
|
|
|
+ mode: 1,
|
|
|
|
+ checked: false,
|
|
|
|
+ show1: false,
|
|
|
|
+ show2: false,
|
|
|
|
+ code: "",
|
|
|
|
+ order_no: "",
|
|
|
|
+ orderinfo: "",
|
|
|
|
+ address: "",
|
|
|
|
+ useraddr: "",
|
|
|
|
+ remark: "",
|
|
|
|
+ address_id:0,
|
|
|
|
|
|
},
|
|
},
|
|
- onLoad() {
|
|
|
|
|
|
+ onLoad(opticon) {
|
|
|
|
+ let order_no = opticon.order_no;
|
|
let currentList = this.data.currentList
|
|
let currentList = this.data.currentList
|
|
currentList.map(item => {
|
|
currentList.map(item => {
|
|
item.active = false
|
|
item.active = false
|
|
})
|
|
})
|
|
|
|
+ this.detail(order_no);
|
|
this.setData({
|
|
this.setData({
|
|
- currentList
|
|
|
|
|
|
+ currentList,
|
|
|
|
+ order_no
|
|
})
|
|
})
|
|
|
|
+
|
|
},
|
|
},
|
|
|
|
+ //详情
|
|
|
|
+ detail(order) {
|
|
|
|
+ var that = this;
|
|
|
|
+ app.api.useApi(app.globalData.baseAppUrl + "api/order_detail", {
|
|
|
|
+ order_no: order,
|
|
|
|
+ }, "get").then(function (res) {
|
|
|
|
+ if (res.code != 200) {
|
|
|
|
+ wx.showLoading({
|
|
|
|
+ title: res.message.msg,
|
|
|
|
+ })
|
|
|
|
+ setTimeout(function () {
|
|
|
|
+ wx.hideLoading({
|
|
|
|
+ success: (res) => { },
|
|
|
|
+ })
|
|
|
|
+ }, 2000);
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ that.setData({
|
|
|
|
+ orderinfo: res.message.data,
|
|
|
|
+ address: res.message.address.address,
|
|
|
|
+ code: res.message.address.phone,
|
|
|
|
+ name: res.message.address.username,
|
|
|
|
+ address_id:res.message.address.id,
|
|
|
|
+ useraddr: res.message.address,
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
|
|
- changeClose1(e){
|
|
|
|
|
|
+ }).catch(function (err) {
|
|
|
|
+ console.log(222);
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ changeClose1(e) {
|
|
this.setData({
|
|
this.setData({
|
|
- show1:!this.data.show1
|
|
|
|
|
|
+ show1: !this.data.show1
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
- changeClose2(e){
|
|
|
|
|
|
+ changeClose2(e) {
|
|
this.setData({
|
|
this.setData({
|
|
- show2:!this.data.show2
|
|
|
|
|
|
+ show2: !this.data.show2,
|
|
|
|
+ remark: this.data.remark
|
|
})
|
|
})
|
|
|
|
+
|
|
},
|
|
},
|
|
onChange(event) {
|
|
onChange(event) {
|
|
console.log(event);
|
|
console.log(event);
|
|
this.setData({
|
|
this.setData({
|
|
checked: event.detail,
|
|
checked: event.detail,
|
|
});
|
|
});
|
|
- },
|
|
|
|
- chios(e){
|
|
|
|
- let {item} = e.currentTarget.dataset
|
|
|
|
|
|
+ },
|
|
|
|
+ chios(e) {
|
|
|
|
+ let { item } = e.currentTarget.dataset
|
|
|
|
|
|
let currentList = this.data.currentList
|
|
let currentList = this.data.currentList
|
|
- currentList.map((it,index)=>{
|
|
|
|
|
|
+ currentList.map((it, index) => {
|
|
if (item.id == it.id) {
|
|
if (item.id == it.id) {
|
|
it.active = !it.active
|
|
it.active = !it.active
|
|
}
|
|
}
|
|
@@ -70,55 +113,177 @@ Page({
|
|
currentList
|
|
currentList
|
|
})
|
|
})
|
|
},
|
|
},
|
|
- changeMode(e){
|
|
|
|
- let {mode} = e.currentTarget.dataset
|
|
|
|
|
|
+ changeMode(e) {
|
|
|
|
+ var id = e.target.dataset.id
|
|
|
|
+ console.log(id);
|
|
this.setData({
|
|
this.setData({
|
|
- mode
|
|
|
|
|
|
+ mode: id
|
|
})
|
|
})
|
|
},
|
|
},
|
|
- goto(){
|
|
|
|
- wx.navigateTo({
|
|
|
|
- url:'/pages/my/cashier/cashier'
|
|
|
|
- })
|
|
|
|
|
|
+
|
|
|
|
+ goto() {
|
|
|
|
+ if(!this.data.checked){
|
|
|
|
+ wx.showLoading({
|
|
|
|
+ title: '请阅读并同意洗护协议',
|
|
|
|
+ })
|
|
|
|
+ setTimeout(function () {
|
|
|
|
+ wx.hideLoading({
|
|
|
|
+ success: (res) => { },
|
|
|
|
+ })
|
|
|
|
+ }, 1000);
|
|
|
|
+ }else{this.orderConfirm();}
|
|
|
|
+
|
|
},
|
|
},
|
|
- getPhoneNumber (e){
|
|
|
|
|
|
+ getPhoneNumber(e) {
|
|
app.login();
|
|
app.login();
|
|
console.log(e)
|
|
console.log(e)
|
|
-
|
|
|
|
- var data={
|
|
|
|
- 'mds':wx.getStorageSync('seisson_key'),
|
|
|
|
- 'encryptedData':e.detail.encryptedData,
|
|
|
|
- 'errMsg':e.detail.errMsg,
|
|
|
|
- 'iv':e.detail.iv,
|
|
|
|
- 'appid':wx.getAppBaseInfo().host.appId,
|
|
|
|
- 'token':wx.getStorageSync('token')
|
|
|
|
- }
|
|
|
|
- wx.cloud.callFunction({
|
|
|
|
- name: 'getPhoneNumber',
|
|
|
|
- data:{
|
|
|
|
- 'message':data
|
|
|
|
- },
|
|
|
|
- success:res=>{
|
|
|
|
- console.log(res)
|
|
|
|
- var par=res.result.original;
|
|
|
|
- if(par.code==200){
|
|
|
|
- var phone=par.message.data.phone
|
|
|
|
- if(phone){
|
|
|
|
|
|
+
|
|
|
|
+ var data = {
|
|
|
|
+ 'mds': wx.getStorageSync('seisson_key'),
|
|
|
|
+ 'encryptedData': e.detail.encryptedData,
|
|
|
|
+ 'errMsg': e.detail.errMsg,
|
|
|
|
+ 'iv': e.detail.iv,
|
|
|
|
+ 'appid': wx.getAppBaseInfo().host.appId,
|
|
|
|
+ 'token': wx.getStorageSync('token')
|
|
|
|
+ }
|
|
|
|
+ wx.cloud.callFunction({
|
|
|
|
+ name: 'getPhoneNumber',
|
|
|
|
+ data: {
|
|
|
|
+ 'message': data
|
|
|
|
+ },
|
|
|
|
+ success: res => {
|
|
|
|
+ console.log(res)
|
|
|
|
+ var par = res.result.original;
|
|
|
|
+ if (par.code == 200) {
|
|
|
|
+ var phone = par.message.data.phone
|
|
|
|
+ if (phone) {
|
|
this.setData({
|
|
this.setData({
|
|
code: phone,
|
|
code: phone,
|
|
- })
|
|
|
|
|
|
+ })
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }
|
|
},
|
|
},
|
|
- fail:err=>{
|
|
|
|
- console.log(err)
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
-
|
|
|
|
- // console.log("fetch cloudfunction success", cloudResult.result)
|
|
|
|
-
|
|
|
|
|
|
+ fail: err => {
|
|
|
|
+ console.log(err)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ // console.log("fetch cloudfunction success", cloudResult.result)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ input1(e) {
|
|
|
|
+ console.log(e.detail);
|
|
|
|
+ this.setData({
|
|
|
|
+ name: e.detail.value
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ input2(e) {
|
|
|
|
+ this.setData({
|
|
|
|
+ code: e.detail.value
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ input3(e) {
|
|
|
|
+ this.setData({
|
|
|
|
+ address: e.detail.value
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ input4(e) {
|
|
|
|
+ this.setData({
|
|
|
|
+ remark: e.detail.value
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ },
|
|
|
|
+ addAddress() {
|
|
|
|
+ var that = this;
|
|
|
|
+ app.api.useApi(app.globalData.baseAppUrl + "api/address/create", {
|
|
|
|
+ username: that.data.name,
|
|
|
|
+ phone: that.data.code,
|
|
|
|
+ address: that.data.address,
|
|
|
|
+
|
|
|
|
+ }, "post").then(function (res) {
|
|
|
|
+ if (res.code != 200) {
|
|
|
|
+ wx.showLoading({
|
|
|
|
+ title: res.message.msg,
|
|
|
|
+ })
|
|
|
|
+ setTimeout(function () {
|
|
|
|
+ wx.hideLoading({
|
|
|
|
+ success: (res) => { },
|
|
|
|
+ })
|
|
|
|
+ }, 1000);
|
|
|
|
+ } else {
|
|
|
|
+ that.changeClose1();
|
|
|
|
+ that.setData({
|
|
|
|
+ address_id: res.message.data.message.id,
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }).catch(function (err) {
|
|
|
|
+ console.log(222);
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ updateaddr(e) {
|
|
|
|
+ var that = this;
|
|
|
|
+ app.api.useApi(app.globalData.baseAppUrl + "api/address/update", {
|
|
|
|
+ username: that.data.name,
|
|
|
|
+ phone: that.data.code,
|
|
|
|
+ address: that.data.address,
|
|
|
|
+ id: e.target.dataset.id,
|
|
|
|
+ }, "post").then(function (res) {
|
|
|
|
+ if (res.original.code != 200) {
|
|
|
|
+ wx.showLoading({
|
|
|
|
+ title: res.original.message.msg,
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ that.changeClose1();
|
|
|
|
+ // wx.navigateTo({
|
|
|
|
+ // url: '/pages/my/address/address',
|
|
|
|
+ // })
|
|
|
|
+ }
|
|
|
|
+ setTimeout(function () {
|
|
|
|
+ wx.hideLoading({
|
|
|
|
+ success: (res) => { },
|
|
|
|
+ })
|
|
|
|
+ }, 2000);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }).catch(function (err) {
|
|
|
|
+ console.log(222);
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ orderConfirm() {
|
|
|
|
+ var that=this;
|
|
|
|
+ app.api.useApi(app.globalData.baseAppUrl + "api/orders", {
|
|
|
|
+ order_no: that.data.order_no,
|
|
|
|
+ order_type: that.data.mode,
|
|
|
|
+ user_remark: that.data.remark,
|
|
|
|
+ address_id:that.data.address_id
|
|
|
|
+ }, "post").then(function (res) {
|
|
|
|
+ if (res.original.code != 200) {
|
|
|
|
+ wx.showLoading({
|
|
|
|
+ title: res.original.message.msg,
|
|
|
|
+ })
|
|
|
|
+ setTimeout(function () {
|
|
|
|
+ wx.hideLoading({
|
|
|
|
+ success: (res) => { },
|
|
|
|
+ })
|
|
|
|
+ }, 1000);
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ wx.navigateTo({
|
|
|
|
+ url: '/pages/my/cashier/cashier'
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }).catch(function (err) {
|
|
|
|
+ console.log(222);
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- }
|
|
|
|
})
|
|
})
|