Commit ccb30006170cb1eb7cb68bb32297b71ac1b18d9e

Authored by wangfan
1 parent 508f95c5

manager-invitation

@@ -10,11 +10,12 @@ Page({ @@ -10,11 +10,12 @@ Page({
10 data: { 10 data: {
11 hasSubmit:false, 11 hasSubmit:false,
12 form:{ 12 form:{
13 - name:'',  
14 - addr:'',  
15 id:'', 13 id:'',
16 - latitude:'',  
17 - longitude:'', 14 + name:'',
  15 + address:'',
  16 + lat:'',
  17 + long:'',
  18 + is_default:'',
18 }, 19 },
19 }, 20 },
20 21
@@ -22,54 +23,12 @@ Page({ @@ -22,54 +23,12 @@ Page({
22 * 生命周期函数--监听页面加载 23 * 生命周期函数--监听页面加载
23 */ 24 */
24 onLoad: function (options) { 25 onLoad: function (options) {
25 - this.initData(options)  
26 - this.setData({  
27 - options:options,  
28 - })  
29 - },  
30 - initData(options){  
31 - if(options.rid){  
32 - App.Invitation.Detail({id:options.rid}).then(res=>{  
33 - this.setData({  
34 - form:{  
35 - sid:res.data.seller_name,  
36 - name:res.data.seller_name,  
37 - room:res.data.room_name,  
38 - addr:res.data.seller_address,  
39 - sid:res.data.sid,  
40 - time:res.data.arrival_time,  
41 - image:res.data.image_url,  
42 - latitude:res.data.lat,  
43 - longitude:res.data.long,  
44 - },  
45 - timeStr:util.unixtoTime(res.data.arrival_time,this.data.tpl.timeStr)  
46 - })  
47 - })  
48 - }else{  
49 - App.Invitation.GetSellerList({  
50 - openid:getApp().openid  
51 - }).then(res=>{  
52 - if(res.data.length>0){  
53 - let defi=0;  
54 - for(let i=0;i<res.data.length;i++){  
55 - if(res.data[i].is_default==1){  
56 - defi=i;  
57 - break;  
58 - }  
59 - }  
60 - let sel=res.data[defi];  
61 - this.setData({  
62 - form:{  
63 - sid:sel.id,  
64 - name:sel.name,  
65 - addr:sel.address,  
66 - latitude:sel.lat,  
67 - longitude:sel.long,  
68 - }  
69 - })  
70 - } 26 + if(options.seller){
  27 + this.setData({
  28 + form:JSON.parse(options.seller),
71 }) 29 })
72 } 30 }
  31 +
73 }, 32 },
74 /** 33 /**
75 * 生命周期函数--监听页面初次渲染完成 34 * 生命周期函数--监听页面初次渲染完成
@@ -117,8 +76,8 @@ Page({ @@ -117,8 +76,8 @@ Page({
117 let flag=false; 76 let flag=false;
118 if( 77 if(
119 form.name 78 form.name
120 - && form.addr  
121 - && form.latitude>0 79 + && form.address
  80 + && form.lat>0
122 ){ 81 ){
123 flag=true; 82 flag=true;
124 } 83 }
@@ -128,11 +87,15 @@ Page({ @@ -128,11 +87,15 @@ Page({
128 return flag; 87 return flag;
129 }, 88 },
130 input(e){ 89 input(e){
  90 + console.log(e);
131 let key=util.attr(e,'key'); 91 let key=util.attr(e,'key');
132 - if(key=='addr' && !(this.data.form.latitude>0)){ 92 + if(key=='addr' && !(this.data.form.lat>0)){
133 return this.onChangeAddress() 93 return this.onChangeAddress()
134 } 94 }
135 - let val=util.val(e).trim(); 95 + let val=util.val(e);
  96 + if(typeof val=='String'){
  97 + val=val.trim();
  98 + }
136 let form=this.data.form; 99 let form=this.data.form;
137 form[key]=val; 100 form[key]=val;
138 this.setData({ 101 this.setData({
@@ -143,29 +106,32 @@ Page({ @@ -143,29 +106,32 @@ Page({
143 submit(){ 106 submit(){
144 if(!this.checkHasSubmit()){ 107 if(!this.checkHasSubmit()){
145 let msg='请完善信息'; 108 let msg='请完善信息';
146 - if(this.data.form.latitude<1){ 109 + if(this.data.form.lat<1){
147 msg='请标注店铺位置' 110 msg='请标注店铺位置'
148 } 111 }
149 return util.toast(msg,'none') 112 return util.toast(msg,'none')
150 } 113 }
151 - let opt=this.data.options  
152 let param={ 114 let param={
153 openid:getApp().openid, 115 openid:getApp().openid,
154 - sid:this.data.form.sid, 116 + sid:this.data.form.id,
155 sname:this.data.form.name, 117 sname:this.data.form.name,
156 - seller_address:this.data.form.addr,  
157 - lat:this.data.form.latitude,  
158 - long:this.data.form.longitude, 118 + address:this.data.form.address,
  119 + lat:this.data.form.lat,
  120 + long:this.data.form.long,
  121 + is_default:(this.data.form.is_default==true || this.data.form.is_default==1)?1:0,
159 } 122 }
  123 + App.Invitation.SetSellerInfo(param).then(res=>{
  124 + wx.navigateBack();
  125 + })
160 }, 126 },
161 onChangeAddress(){ 127 onChangeAddress(){
162 wx.chooseLocation({ 128 wx.chooseLocation({
163 success: (res)=> { 129 success: (res)=> {
164 console.log(res); 130 console.log(res);
165 this.setData({ 131 this.setData({
166 - [`form.latitude`]:res.latitude,  
167 - [`form.longitude`]:res.longitude,  
168 - [`form.addr`]:res.name, 132 + [`form.lat`]:res.latitude,
  133 + [`form.long`]:res.longitude,
  134 + [`form.address`]:res.name,
169 }) 135 })
170 this.checkHasSubmit() 136 this.checkHasSubmit()
171 }, 137 },
1 <!--pages/manager-invitation/editor.wxml--> 1 <!--pages/manager-invitation/editor.wxml-->
2 -<nav>修改信息</nav> 2 +<nav>工作的店铺</nav>
3 <view class="pages"> 3 <view class="pages">
4 <view class="base block"> 4 <view class="base block">
5 - <view class="item Medium">预订信息</view> 5 + <view class="item Medium">店铺信息</view>
6 <view class="item flex-ll"> 6 <view class="item flex-ll">
7 <input value="{{form.name}}" bindinput="input" 7 <input value="{{form.name}}" bindinput="input"
8 data-key="name" 8 data-key="name"
9 placeholder="请输入店铺名称" placeholder-class="placeholder-class"/> 9 placeholder="请输入店铺名称" placeholder-class="placeholder-class"/>
10 - <view class="quick">快速选择</view>  
11 </view> 10 </view>
12 <view class="item flex-ll"> 11 <view class="item flex-ll">
13 - <picker  
14 - mode="multiSelector"  
15 - bindchange="bindMultiPickerChange"  
16 - bindcolumnchange="bindMultiPickerColumnChange"  
17 - value="{{pickerValue}}"  
18 - range="{{pickerData}}"  
19 - style="width: 100%"  
20 - >  
21 - <view class="picker" style="width: 100%;">  
22 - <!--  
23 - <block wx:if="{{pickerValue[0]>-1}}">  
24 - {{pickerData[0][pickerValue[0]]}} {{pickerData[1][pickerValue[1]]}} {{pickerData[2][pickerValue[2]]}}  
25 - </block>  
26 - -->  
27 - <text wx:if="{{timeStr}}">{{timeStr}}</text>  
28 - <text class="placeholder-class" wx:else="">请输入预订时间</text>  
29 - </view>  
30 - </picker>  
31 - </view>  
32 - <view class="item flex-ll">  
33 - <input value="{{form.room}}" bindinput="input"  
34 - data-key="room"  
35 - placeholder="请输入包间名称" placeholder-class="placeholder-class"/>  
36 - </view>  
37 - <view class="item flex-ll">  
38 - <input value="{{form.addr}}" 12 + <input value="{{form.address}}"
39 bindinput="input" bindfocus="input" 13 bindinput="input" bindfocus="input"
40 - data-key="addr" 14 + data-key="address"
41 placeholder="请输入店铺地址" placeholder-class="placeholder-class"/> 15 placeholder="请输入店铺地址" placeholder-class="placeholder-class"/>
42 <view class="caddr flex-rr" bindtap="onChangeAddress"> 16 <view class="caddr flex-rr" bindtap="onChangeAddress">
43 <image src="http://qn.colorcun.com/manager-invitation/wx/caddr.png" style="width: 28rpx; height: 36rpx;"></image> 17 <image src="http://qn.colorcun.com/manager-invitation/wx/caddr.png" style="width: 28rpx; height: 36rpx;"></image>
44 </view> 18 </view>
45 </view> 19 </view>
  20 + <view class="item flex-lr">
  21 + 设置为默认地址
  22 + <switch checked="{{form.is_default==1}}" bindchange="input" data-key="is_default" />
  23 + </view>
46 </view> 24 </view>
47 - <view class="upload block flex-vc" wx:if="{{tpl.hasImage}}"> 25 + <view class="upload block flex-vc">
  26 + <view class="item Medium">店铺图片</view>
48 <view class="image" bindtap="chooseImage"> 27 <view class="image" bindtap="chooseImage">
49 <image src="{{form.image||defImage}}" mode="aspectFill"></image> 28 <image src="{{form.image||defImage}}" mode="aspectFill"></image>
50 </view> 29 </view>