Commit 3fcd83c5783f6f46890d9e605efe306b39cb8423

Authored by wangfan
1 parent ae8d53cc

manager-invitation

@@ -33,9 +33,36 @@ Page({ @@ -33,9 +33,36 @@ Page({
33 this.pickerData=TP.pickerData(); 33 this.pickerData=TP.pickerData();
34 let pd=TP.pickerData(); 34 let pd=TP.pickerData();
35 pd[2]=pd[2][this.data.pickerValue[1]]; 35 pd[2]=pd[2][this.data.pickerValue[1]];
  36 +
  37 + if(options.rid){
  38 +
  39 + }else{
  40 + App.Invitation.GetSellerList({
  41 + openid:getApp().openid
  42 + }).then(res=>{
  43 + if(res.data.length>0){
  44 + let defi=0;
  45 + for(let i=0;i<res.data.length;i++){
  46 + if(res.data[i].is_default==1){
  47 + defi=i;
  48 + break;
  49 + }
  50 + }
  51 + let sel=res.data[defi];
  52 + this.setData({
  53 + form:{
  54 + sid:sel.id,
  55 + name:sel.name,
  56 + addr:sel.address,
  57 + }
  58 + })
  59 + }
  60 + })
  61 + }
36 this.setData({ 62 this.setData({
37 pickerData:pd, 63 pickerData:pd,
38 tpl:this.tpl, 64 tpl:this.tpl,
  65 + options:options,
39 }) 66 })
40 }, 67 },
41 68
@@ -96,7 +123,8 @@ Page({ @@ -96,7 +123,8 @@ Page({
96 this.checkHasSubmit() 123 this.checkHasSubmit()
97 }, 124 },
98 checkHasSubmit(){ 125 checkHasSubmit(){
99 - let form=this.data.form 126 + let form=this.data.form;
  127 + let flag=false;
100 if( 128 if(
101 form.name 129 form.name
102 && this.data.pickerValue[0]>-1 130 && this.data.pickerValue[0]>-1
@@ -104,14 +132,12 @@ Page({ @@ -104,14 +132,12 @@ Page({
104 && form.addr 132 && form.addr
105 && (!this.tpl.hasImage || (this.tpl.hasImage && form.image))//带图模板 133 && (!this.tpl.hasImage || (this.tpl.hasImage && form.image))//带图模板
106 ){ 134 ){
107 - this.setData({  
108 - hasSubmit:true  
109 - })  
110 - }else{  
111 - this.setData({  
112 - hasSubmit:false  
113 - }) 135 + flag=true;
114 } 136 }
  137 + this.setData({
  138 + hasSubmit:flag
  139 + })
  140 + return flag;
115 }, 141 },
116 input(e){ 142 input(e){
117 let key=util.attr(e,'key'); 143 let key=util.attr(e,'key');
@@ -122,5 +148,38 @@ Page({ @@ -122,5 +148,38 @@ Page({
122 form:form, 148 form:form,
123 }) 149 })
124 this.checkHasSubmit() 150 this.checkHasSubmit()
125 - } 151 + },
  152 + getTimeStr(){
  153 + let d=new Date();
  154 + let y=d.getFullYear();
  155 + let md=this.data.pickerData[0][this.data.pickerValue[0]].substr(0,5);
  156 + let t=this.data.pickerData[2][this.data.pickerValue[2]];
  157 + return util.timetouUnix(y+'-'+md+' '+t+':00');
  158 + },
  159 + submit(){
  160 + if(!this.checkHasSubmit()){
  161 + return util.toast('请完善信息',none)
  162 + }
  163 + let opt=this.data.options
  164 + let param={
  165 + openid:getApp().openid,
  166 + template_id:opt.tplid,
  167 + sid:this.data.form.sid,
  168 + sname:this.data.form.name,
  169 + seller_address:this.data.form.addr,
  170 + room_name:this.data.form.room,
  171 + arrival_time:this.getTimeStr(),
  172 + }
  173 + if(opt.rid){
  174 + param.id=opt.rid
  175 + }
  176 + App.Invitation.SetInvitationInfo(param).then(res=>{
  177 + wx.redirectTo({
  178 + url:util.http_build_query({
  179 + rid:res.data.id,
  180 + ...this.data.options,
  181 + },'./review')
  182 + })
  183 + })
  184 + },
126 }) 185 })
@@ -28,6 +28,25 @@ Page({ @@ -28,6 +28,25 @@ Page({
28 this.setData({ 28 this.setData({
29 dots:dots, 29 dots:dots,
30 }) 30 })
  31 + App.Invitation.UserIdentity({
  32 + openid:getApp().openid
  33 + }).then(res=>{
  34 + if(res.ret==200){
  35 + if(res.data.identity==1){
  36 + // wx.reLaunch({
  37 + // url:'/pages/customer/index'
  38 + // })
  39 + // return;
  40 + }
  41 + if(res.data.identity==2){
  42 + wx.redirectTo({
  43 + url:'/pages/manager-invitation/review'
  44 + })
  45 + }
  46 + }else{
  47 + util.toast(res.msg)
  48 + }
  49 + })
31 }, 50 },
32 51
33 /** 52 /**
@@ -79,8 +98,16 @@ Page({ @@ -79,8 +98,16 @@ Page({
79 98
80 }, 99 },
81 userinfo(){ 100 userinfo(){
82 - wx.redirectTo({  
83 - url:'./review'  
84 - }); 101 + let us=util.cache('userInfo');
  102 + App.Invitation.AddInvitationUser({
  103 + openid:getApp().openid,
  104 + avatar:us.avatarUrl,
  105 + nickname:us.nickName,
  106 + gender:us.gender,
  107 + }).then(res=>{
  108 + wx.redirectTo({
  109 + url:'./review'
  110 + });
  111 + })
85 }, 112 },
86 }) 113 })
@@ -17,16 +17,52 @@ Page({ @@ -17,16 +17,52 @@ Page({
17 room:'天香阁', 17 room:'天香阁',
18 date:util.unixtoTime(new Date()/1000,'YYYY/MM/DD 星期WW HH:II'), 18 date:util.unixtoTime(new Date()/1000,'YYYY/MM/DD 星期WW HH:II'),
19 addr:'粤江西路啤酒文化创意艺术区B09' 19 addr:'粤江西路啤酒文化创意艺术区B09'
20 - } 20 + },
  21 + options:{},
21 }, 22 },
22 23
23 /** 24 /**
24 * 生命周期函数--监听页面加载 25 * 生命周期函数--监听页面加载
25 */ 26 */
26 onLoad: function (options) { 27 onLoad: function (options) {
  28 + let param={
  29 + options:options,
  30 + }
  31 + if(options.rid){
  32 + param.tpls=[TP.tpls(options.tplid)]
  33 + }
  34 + this.setData(param)
  35 + this.initData(options);
27 36
28 }, 37 },
29 - 38 + initData(options){
  39 + if(options.rid){
  40 +
  41 + }else{
  42 + App.Invitation.GetSellerList({
  43 + openid:getApp().openid
  44 + }).then(res=>{
  45 + if(res.data.length>0){
  46 + let defi=0;
  47 + for(let i=0;i<res.data.length;i++){
  48 + if(res.data[i].is_default==1){
  49 + defi=i;
  50 + break;
  51 + }
  52 + }
  53 + let sel=res.data[defi];
  54 + this.setData({
  55 + seller:{
  56 + name:sel.name,
  57 + room:'',
  58 + date:util.unixtoTime(new Date()/1000,this.data.tpls[this.data.current].timeStr),
  59 + addr:sel.address
  60 + }
  61 + })
  62 + }
  63 + })
  64 + }
  65 + },
30 /** 66 /**
31 * 生命周期函数--监听页面初次渲染完成 67 * 生命周期函数--监听页面初次渲染完成
32 */ 68 */
@@ -102,8 +138,12 @@ Page({ @@ -102,8 +138,12 @@ Page({
102 }) 138 })
103 }, 139 },
104 goEditor(){ 140 goEditor(){
  141 + let param={
  142 + ...this.data.options,
  143 + tplid:this.data.tpls[this.data.current].id,
  144 + }
105 wx.navigateTo({ 145 wx.navigateTo({
106 - url:'./editor?tplid='+this.data.tpls[this.data.current].id 146 + url:util.http_build_query(param,'./editor')
107 }) 147 })
108 }, 148 },
109 }) 149 })
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 </swiper-item> 15 </swiper-item>
16 </block> 16 </block>
17 </swiper> 17 </swiper>
18 -<view 18 +<view wx:if="{{!options.rid}}"
19 class="flex-vc" 19 class="flex-vc"
20 style="position:fixed;top:{{statusBarHeight}}px;left:0;height: {{titleBarHeight}}px; line-height: {{titleBarHeight}}px;"> 20 style="position:fixed;top:{{statusBarHeight}}px;left:0;height: {{titleBarHeight}}px; line-height: {{titleBarHeight}}px;">
21 <view class="tabs flex-ll"> 21 <view class="tabs flex-ll">
@@ -24,13 +24,13 @@ @@ -24,13 +24,13 @@
24 </block> 24 </block>
25 </view> 25 </view>
26 </view> 26 </view>
27 -<view class="editor flex-vc" bindtap="goEditor">修改内容</view> 27 +<view class="editor flex-vc" bindtap="goEditor" wx:if="{{!options.rid}}">修改内容</view>
28 <!--//商务--> 28 <!--//商务-->
29 <template name="tpl-1"> 29 <template name="tpl-1">
30 <view class="flex-vc shangwu"> 30 <view class="flex-vc shangwu">
31 <view class="invit-logo"> 31 <view class="invit-logo">
32 <image src="http://qn.colorcun.com/custom/lite-yd-cook/image/detail_owner_invitation-1-1.png"></image> 32 <image src="http://qn.colorcun.com/custom/lite-yd-cook/image/detail_owner_invitation-1-1.png"></image>
33 - <view class="quick-editor">修改内容</view> 33 + <view class="quick-editor" wx:if="{{options.rid}}">修改内容</view>
34 </view> 34 </view>
35 <view class="seller flex-vc"> 35 <view class="seller flex-vc">
36 <view class="title">餐厅</view> 36 <view class="title">餐厅</view>
@@ -45,7 +45,7 @@ @@ -45,7 +45,7 @@
45 {{addr}}第三方斯蒂芬 45 {{addr}}第三方斯蒂芬
46 </view> 46 </view>
47 </view> 47 </view>
48 - <userinfo-share class="button-none flex-vc" binduserinfo="setUserInfoSuccess"> 48 + <userinfo-share class="button-none flex-vc" binduserinfo="setUserInfoSuccess" wx:if="{{options.rid}}">
49 <view class="buts-share"></view> 49 <view class="buts-share"></view>
50 </userinfo-share> 50 </userinfo-share>
51 </view> 51 </view>
@@ -58,7 +58,7 @@ @@ -58,7 +58,7 @@
58 <view class="flex-vc wenxin"> 58 <view class="flex-vc wenxin">
59 <view class="invit-logo"> 59 <view class="invit-logo">
60 <image src="http://qn.colorcun.com/manager-invitation/wx/%E6%B8%A9%E9%A6%A8-%E9%A2%84%E8%AE%A2%E5%AE%89%E6%8E%92.png"></image> 60 <image src="http://qn.colorcun.com/manager-invitation/wx/%E6%B8%A9%E9%A6%A8-%E9%A2%84%E8%AE%A2%E5%AE%89%E6%8E%92.png"></image>
61 - <view class="quick-editor">修改内容</view> 61 + <view class="quick-editor" wx:if="{{options.rid}}">修改内容</view>
62 </view> 62 </view>
63 <view class="wenxin-mask"> 63 <view class="wenxin-mask">
64 <view class="wenxin-mask-bg"></view> 64 <view class="wenxin-mask-bg"></view>
@@ -74,7 +74,7 @@ @@ -74,7 +74,7 @@
74 {{addr}} 74 {{addr}}
75 </view> 75 </view>
76 </view> 76 </view>
77 - <userinfo-share class="button-none flex-vc" binduserinfo="setUserInfoSuccess"> 77 + <userinfo-share class="button-none flex-vc" binduserinfo="setUserInfoSuccess" wx:if="{{options.rid}}">
78 <view class="buts-share"></view> 78 <view class="buts-share"></view>
79 </userinfo-share> 79 </userinfo-share>
80 </view> 80 </view>
@@ -85,6 +85,7 @@ image{ @@ -85,6 +85,7 @@ image{
85 margin-bottom: 152rpx; 85 margin-bottom: 152rpx;
86 } 86 }
87 .wenxin { 87 .wenxin {
  88 + margin-top: 60rpx;
88 } 89 }
89 90
90 .wenxin-top{ 91 .wenxin-top{
@@ -31,7 +31,7 @@ @@ -31,7 +31,7 @@
31 "list": [] 31 "list": []
32 }, 32 },
33 "miniprogram": { 33 "miniprogram": {
34 - "current": 44, 34 + "current": 43,
35 "list": [ 35 "list": [
36 { 36 {
37 "id": 0, 37 "id": 0,
@@ -358,17 +358,17 @@ @@ -358,17 +358,17 @@
358 "scene": null 358 "scene": null
359 }, 359 },
360 { 360 {
361 - "id": -1, 361 + "id": 43,
362 "name": "pages/manager-invitation/review", 362 "name": "pages/manager-invitation/review",
363 "pathName": "pages/manager-invitation/review", 363 "pathName": "pages/manager-invitation/review",
364 - "query": "id=154", 364 + "query": "rid=4&tplid=1",
365 "scene": null 365 "scene": null
366 }, 366 },
367 { 367 {
368 "id": 44, 368 "id": 44,
369 "name": "pages/manager-invitation/editor", 369 "name": "pages/manager-invitation/editor",
370 "pathName": "pages/manager-invitation/editor", 370 "pathName": "pages/manager-invitation/editor",
371 - "query": "tplid=2", 371 + "query": "tplid=1",
372 "scene": null 372 "scene": null
373 } 373 }
374 ] 374 ]
@@ -178,4 +178,26 @@ export default { @@ -178,4 +178,26 @@ export default {
178 178
179 //顾客收藏的店铺列表 179 //顾客收藏的店铺列表
180 'App.Customer.GetCollectionSellerList':null, 180 'App.Customer.GetCollectionSellerList':null,
  181 +
  182 + /**
  183 + * 邀请函
  184 + */
  185 + //根据订座的openid 获取当前用户身份
  186 + 'App.Invitation.UserIdentity':null,
  187 +
  188 + //增加客户经理基本信息
  189 + 'App.Invitation.AddInvitationUser':null,
  190 +
  191 + //获取商家列表
  192 + 'App.Invitation.GetSellerList':{
  193 + //cachetime: -1,
  194 + },
  195 +
  196 + //编辑、增加商家信息
  197 + 'App.Invitation.SetSellerInfo':null,
  198 +
  199 + //修改、录入邀请函信息,同时生成对应的商家信息
  200 + 'App.Invitation.SetInvitationInfo':{
  201 + silence: false,
  202 + },
181 } 203 }
@@ -5,12 +5,14 @@ let tpls=[ @@ -5,12 +5,14 @@ let tpls=[
5 code: 1, 5 code: 1,
6 name: '商务', 6 name: '商务',
7 hasImage:false, 7 hasImage:false,
  8 + timeStr:'YYYY/MM/DD 星期WW HH:II',
8 }, 9 },
9 { 10 {
10 id: 2, 11 id: 2,
11 code: 2, 12 code: 2,
12 name: '温馨', 13 name: '温馨',
13 hasImage:true, 14 hasImage:true,
  15 + timeStr:'YYYY年MM月DD日HH时II分',
14 }, 16 },
15 ]; 17 ];
16 module.exports ={ 18 module.exports ={