Commit f9c4a6acb3aa773446f8869fecfd65c343c1b79e

Authored by yiren
1 parent 697968fe

会员录入判断是否录入过,修改和新增接口

@@ -97,8 +97,35 @@ Page({ @@ -97,8 +97,35 @@ Page({
97 totalize: (price * num1).toFixed(2) 97 totalize: (price * num1).toFixed(2)
98 }) 98 })
99 }, 99 },
  100 + // 输入事件
  101 + bindKeyNameInput(event){
  102 + let price = this.data.detail.price * 1;
  103 + const value = event.detail.value.replace(/\s+/g, "")*1;
  104 + if(value && /(^[1-9]\d*$)/.test(value)){
  105 + wx.hideToast()
  106 + this.setData({
  107 + num: value,
  108 + totalize: (price * value).toFixed(2)
  109 + })
  110 + }else{
  111 + wx.showToast({
  112 + title:'请输入正整数',
  113 + icon:'none',
  114 + duration:1000,
  115 + mask:true,
  116 + })
  117 + }
  118 + },
100 // 提交订单 119 // 提交订单
101 submitOrder() { 120 submitOrder() {
  121 + if(this.data.num && !/(^[1-9]\d*$)/.test(this.data.num)){
  122 + return wx.showToast({
  123 + title:'请输入正确的购买数量',
  124 + duration:2000,
  125 + mask:true,
  126 + icon:'none'
  127 + })
  128 + }
102 if(this.data.detail.grant_last=='0'){ 129 if(this.data.detail.grant_last=='0'){
103 return wx.showToast({ 130 return wx.showToast({
104 title:'您来晚了,当前优惠券已经售罄,请与商家联系!', 131 title:'您来晚了,当前优惠券已经售罄,请与商家联系!',
@@ -13,7 +13,7 @@ @@ -13,7 +13,7 @@
13 </view> 13 </view>
14 <view class="operation"> 14 <view class="operation">
15 <image class="countimgs" src="https://qn.colorcun.com/WechatIMG699.png" bindtap="subtraction"/> 15 <image class="countimgs" src="https://qn.colorcun.com/WechatIMG699.png" bindtap="subtraction"/>
16 - <input type="number" model:value="{{num}}" /> 16 + <input type="number" model:value="{{num}}" bindinput="bindKeyNameInput"/>
17 <image class="countimgs" src="https://qn.colorcun.com/WechatIMG698.png" bindtap="addition" mode=""/> 17 <image class="countimgs" src="https://qn.colorcun.com/WechatIMG698.png" bindtap="addition" mode=""/>
18 </view> 18 </view>
19 </view> 19 </view>
@@ -81,9 +81,10 @@ Page({ @@ -81,9 +81,10 @@ Page({
81 showModal() { 81 showModal() {
82 this.modal.showModal() //调用组件中打开模态框方法 82 this.modal.showModal() //调用组件中打开模态框方法
83 }, 83 },
84 - confirmPayment() { 84 + confirmPayment(gid) {
85 App.PayOnline.CombineTransactionsByNewRecharge({ 85 App.PayOnline.CombineTransactionsByNewRecharge({
86 - combine_out_trade_no: this.data.opt.combine_out_trade_no 86 + combine_out_trade_no: this.data.opt.combine_out_trade_no,
  87 + gid:gid?gid:'',
87 }).then(res => { 88 }).then(res => {
88 console.log(res.data); 89 console.log(res.data);
89 let that = this; 90 let that = this;
@@ -99,7 +100,6 @@ Page({ @@ -99,7 +100,6 @@ Page({
99 }) 100 })
100 } 101 }
101 if (res.ret == '200') { 102 if (res.ret == '200') {
102 - console.log(res.ret);  
103 wx.requestPayment({ 103 wx.requestPayment({
104 timeStamp: res.data.timeStamp + '', 104 timeStamp: res.data.timeStamp + '',
105 nonceStr: res.data.nonceStr, 105 nonceStr: res.data.nonceStr,
@@ -223,24 +223,53 @@ Page({ @@ -223,24 +223,53 @@ Page({
223 }, 3500); 223 }, 3500);
224 return 224 return
225 } 225 }
226 - this.addInfo() 226 + this.getInfo()
227 } else { 227 } else {
228 this.confirmPayment() 228 this.confirmPayment()
229 } 229 }
230 }, 230 },
231 - addInfo() {  
232 - let params = {  
233 - sellerid: this.data.opt.sid,  
234 - rname: this.data.name,  
235 - sex: this.data.indexs * 1 + 1, //1男 2女 3公司 231 + getInfo() {
  232 + let sex = this.data.indexs * 1 + 1; //1男 2女 3公司
  233 + App.GuestManage.GetIsMemberByPhone({
  234 + sid: this.data.opt.sid,
236 phone: this.data.phone, 235 phone: this.data.phone,
237 - c_day: this.data.calendarData  
238 - }  
239 - console.log({...params}); 236 + }).then(res => {
  237 + console.log('用户是否录入',res);
  238 + let params = {
  239 + sellerid: this.data.opt.sid,
  240 + rname: this.data.name,
  241 + sex,
  242 + phone: this.data.phone,
  243 + c_day: this.data.calendarData
  244 + }
  245 + console.log({...params});
  246 + if (res.data && res.data.id) {
  247 + if (this.data.phone == res.data.phone && this.data.name == res.data.rname && sex == res.data.sex && this.data.calendarData == res.data.c_day) {
  248 + console.log('信息都一样,直接支付');
  249 + this.confirmPayment(res.data.id)
  250 + } else {
  251 + params.id=res.data.id;
  252 + console.log('要修改信息');
  253 + this.editInfo(params)
  254 + }
  255 + } else {
  256 + console.log('没有客户信息,保存信息');
  257 + this.addInfo(params)
  258 + }
  259 + })
  260 + },
  261 + // 修改客户信息
  262 + editInfo(params) {
  263 + App.GuestManage.SetGuestInfo(params).then(res => {
  264 + if (res.data) {
  265 + this.confirmPayment(params.id)
  266 + }
  267 + })
  268 + },
  269 + // 新增客户信息
  270 + addInfo(params) {
240 App.GuestManage.InsGuest(params).then(res => { 271 App.GuestManage.InsGuest(params).then(res => {
241 - console.log(res);  
242 - if (res.ret == '200') {  
243 - this.confirmPayment() 272 + if (res.ret == '200' && res.data && res.data.id) {
244 let obj = { 273 let obj = {
245 name: this.data.name, 274 name: this.data.name,
246 phone: this.data.phone, 275 phone: this.data.phone,
@@ -249,13 +278,14 @@ Page({ @@ -249,13 +278,14 @@ Page({
249 date: this.data.date, 278 date: this.data.date,
250 } 279 }
251 wx.setStorageSync('info', obj) 280 wx.setStorageSync('info', obj)
  281 + this.confirmPayment(res.data.id)
252 } 282 }
253 }) 283 })
254 }, 284 },
255 // 选择日期 285 // 选择日期
256 bind_ChangeDate(event) { 286 bind_ChangeDate(event) {
257 let date = event.detail.value 287 let date = event.detail.value
258 - var calendarData = new Date(date) * 1/1000; 288 + var calendarData = new Date(date) * 1 / 1000;
259 this.setData({ 289 this.setData({
260 date, 290 date,
261 calendarData 291 calendarData
@@ -700,6 +700,14 @@ export default { @@ -700,6 +700,14 @@ export default {
700 'App.Advance.GetOrderInfo':{ 700 'App.Advance.GetOrderInfo':{
701 openid:'openid' 701 openid:'openid'
702 }, 702 },
703 -  
704 703
  704 + // 获取手机号是否为商家会员
  705 + 'App.GuestManage.GetIsMemberByPhone':{
  706 + openid:'openid'
  707 + },
  708 +
  709 + // 修改客户信息
  710 + 'App.GuestManage.SetGuestInfo':{
  711 + openid:'openid'
  712 + },
705 } 713 }