Commit ccb30006170cb1eb7cb68bb32297b71ac1b18d9e

Authored by wangfan
1 parent 508f95c5

manager-invitation

... ... @@ -10,11 +10,12 @@ Page({
data: {
hasSubmit:false,
form:{
name:'',
addr:'',
id:'',
latitude:'',
longitude:'',
name:'',
address:'',
lat:'',
long:'',
is_default:'',
},
},
... ... @@ -22,54 +23,12 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.initData(options)
this.setData({
options:options,
})
},
initData(options){
if(options.rid){
App.Invitation.Detail({id:options.rid}).then(res=>{
this.setData({
form:{
sid:res.data.seller_name,
name:res.data.seller_name,
room:res.data.room_name,
addr:res.data.seller_address,
sid:res.data.sid,
time:res.data.arrival_time,
image:res.data.image_url,
latitude:res.data.lat,
longitude:res.data.long,
},
timeStr:util.unixtoTime(res.data.arrival_time,this.data.tpl.timeStr)
})
})
}else{
App.Invitation.GetSellerList({
openid:getApp().openid
}).then(res=>{
if(res.data.length>0){
let defi=0;
for(let i=0;i<res.data.length;i++){
if(res.data[i].is_default==1){
defi=i;
break;
}
}
let sel=res.data[defi];
this.setData({
form:{
sid:sel.id,
name:sel.name,
addr:sel.address,
latitude:sel.lat,
longitude:sel.long,
}
})
}
if(options.seller){
this.setData({
form:JSON.parse(options.seller),
})
}
},
/**
* 生命周期函数--监听页面初次渲染完成
... ... @@ -117,8 +76,8 @@ Page({
let flag=false;
if(
form.name
&& form.addr
&& form.latitude>0
&& form.address
&& form.lat>0
){
flag=true;
}
... ... @@ -128,11 +87,15 @@ Page({
return flag;
},
input(e){
console.log(e);
let key=util.attr(e,'key');
if(key=='addr' && !(this.data.form.latitude>0)){
if(key=='addr' && !(this.data.form.lat>0)){
return this.onChangeAddress()
}
let val=util.val(e).trim();
let val=util.val(e);
if(typeof val=='String'){
val=val.trim();
}
let form=this.data.form;
form[key]=val;
this.setData({
... ... @@ -143,29 +106,32 @@ Page({
submit(){
if(!this.checkHasSubmit()){
let msg='请完善信息';
if(this.data.form.latitude<1){
if(this.data.form.lat<1){
msg='请标注店铺位置'
}
return util.toast(msg,'none')
}
let opt=this.data.options
let param={
openid:getApp().openid,
sid:this.data.form.sid,
sid:this.data.form.id,
sname:this.data.form.name,
seller_address:this.data.form.addr,
lat:this.data.form.latitude,
long:this.data.form.longitude,
address:this.data.form.address,
lat:this.data.form.lat,
long:this.data.form.long,
is_default:(this.data.form.is_default==true || this.data.form.is_default==1)?1:0,
}
App.Invitation.SetSellerInfo(param).then(res=>{
wx.navigateBack();
})
},
onChangeAddress(){
wx.chooseLocation({
success: (res)=> {
console.log(res);
this.setData({
[`form.latitude`]:res.latitude,
[`form.longitude`]:res.longitude,
[`form.addr`]:res.name,
[`form.lat`]:res.latitude,
[`form.long`]:res.longitude,
[`form.address`]:res.name,
})
this.checkHasSubmit()
},
... ...
<!--pages/manager-invitation/editor.wxml-->
<nav>修改信息</nav>
<nav>工作的店铺</nav>
<view class="pages">
<view class="base block">
<view class="item Medium">预订信息</view>
<view class="item Medium">店铺信息</view>
<view class="item flex-ll">
<input value="{{form.name}}" bindinput="input"
data-key="name"
placeholder="请输入店铺名称" placeholder-class="placeholder-class"/>
<view class="quick">快速选择</view>
</view>
<view class="item flex-ll">
<picker
mode="multiSelector"
bindchange="bindMultiPickerChange"
bindcolumnchange="bindMultiPickerColumnChange"
value="{{pickerValue}}"
range="{{pickerData}}"
style="width: 100%"
>
<view class="picker" style="width: 100%;">
<!--
<block wx:if="{{pickerValue[0]>-1}}">
{{pickerData[0][pickerValue[0]]}} {{pickerData[1][pickerValue[1]]}} {{pickerData[2][pickerValue[2]]}}
</block>
-->
<text wx:if="{{timeStr}}">{{timeStr}}</text>
<text class="placeholder-class" wx:else="">请输入预订时间</text>
</view>
</picker>
</view>
<view class="item flex-ll">
<input value="{{form.room}}" bindinput="input"
data-key="room"
placeholder="请输入包间名称" placeholder-class="placeholder-class"/>
</view>
<view class="item flex-ll">
<input value="{{form.addr}}"
<input value="{{form.address}}"
bindinput="input" bindfocus="input"
data-key="addr"
data-key="address"
placeholder="请输入店铺地址" placeholder-class="placeholder-class"/>
<view class="caddr flex-rr" bindtap="onChangeAddress">
<image src="http://qn.colorcun.com/manager-invitation/wx/caddr.png" style="width: 28rpx; height: 36rpx;"></image>
</view>
</view>
<view class="item flex-lr">
设置为默认地址
<switch checked="{{form.is_default==1}}" bindchange="input" data-key="is_default" />
</view>
</view>
<view class="upload block flex-vc" wx:if="{{tpl.hasImage}}">
<view class="upload block flex-vc">
<view class="item Medium">店铺图片</view>
<view class="image" bindtap="chooseImage">
<image src="{{form.image||defImage}}" mode="aspectFill"></image>
</view>
... ...