Commit 397851368ba9444237ab545dc0de1b0983e8572a

Authored by wangfan
1 parent 43acf79d

模式切换

@@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
9 <formids class="item flex-vc" bindtap="redirectTo" data-url="/pages/book/b_index"> 9 <formids class="item flex-vc" bindtap="redirectTo" data-url="/pages/book/b_index">
10 <view class="flex-vc {{pi==1?'checked':''}}"> 10 <view class="flex-vc {{pi==1?'checked':''}}">
11 <view class="icon book"></view> 11 <view class="icon book"></view>
12 - <view class="text">预定本</view> 12 + <view class="text">已预订</view>
13 </view> 13 </view>
14 </formids> 14 </formids>
15 <formids class="item flex-vc" bindtap="redirectTo" data-url="/pages/book/b_setting"> 15 <formids class="item flex-vc" bindtap="redirectTo" data-url="/pages/book/b_setting">
@@ -16,5 +16,13 @@ @@ -16,5 +16,13 @@
16 </view> 16 </view>
17 </view> 17 </view>
18 </formids> 18 </formids>
  19 + <formids url="/pages/customer/index?islove=customer">
  20 + <view class="row flex-lr">
  21 + <view>切换到顾客模式</view>
  22 + <view class="flex-rr">
  23 + <view class="more"></view>
  24 + </view>
  25 + </view>
  26 + </formids>
19 </view> 27 </view>
20 <tabBar></tabBar> 28 <tabBar></tabBar>
@@ -12,6 +12,8 @@ Page({ @@ -12,6 +12,8 @@ Page({
12 /** 12 /**
13 * 生命周期函数--监听页面加载 13 * 生命周期函数--监听页面加载
14 */ 14 */
  15 + islove:'',//用户在哪端
  16 + enter_params:'',//商户入口参数
15 async onLoad(opt) { 17 async onLoad(opt) {
16 console.log('onLoad', opt); 18 console.log('onLoad', opt);
17 //转化场景值到opt 19 //转化场景值到opt
@@ -31,10 +33,16 @@ Page({ @@ -31,10 +33,16 @@ Page({
31 this.selectComponent("#network").refresh(); 33 this.selectComponent("#network").refresh();
32 return; 34 return;
33 } 35 }
34 - //进行商户判断  
35 - let flag=await this.SellerForOpenid(opt.openid);  
36 - if(flag) return; 36 + if(opt.islove){
  37 + util.cache('islove',opt.islove);
  38 + this.islove=opt.islove
  39 + }else{
  40 + this.islove=await util.cache('islove')
  41 + }
37 42
  43 + //获得商户数据
  44 + this.enter_params=await this.SellerForOpenid(opt.openid);
  45 + //console.log('this.enter_params',this.enter_params)
38 let url = '/pages/customer/list'; 46 let url = '/pages/customer/list';
39 if (opt.id > 0 || opt.sms_code) { 47 if (opt.id > 0 || opt.sms_code) {
40 if(opt.invite_name){ 48 if(opt.invite_name){
@@ -55,20 +63,28 @@ Page({ @@ -55,20 +63,28 @@ Page({
55 } 63 }
56 64
57 App.Reserve.Detail(param).then(res => { 65 App.Reserve.Detail(param).then(res => {
58 - //设置关系  
59 - App.Reserve.SetRelaOpenid({ 66 + console.log(this.enter_params.seller_openid)
  67 + if(this.enter_params){//商户
  68 + if(res.data.sid==this.enter_params.seller_id && !opt.fromid){//不是客户端分享,且是同一个店的
  69 + util.cache('enter_params',this.enter_params)
  70 + url = '/pages/book/b_detail';
  71 + }
  72 + }
  73 + if(url!='/pages/book/b_detail'){
  74 + //设置关系
  75 + App.Reserve.SetRelaOpenid({
60 rid:res.data.id, 76 rid:res.data.id,
61 openid:opt.openid, 77 openid:opt.openid,
62 fromid:opt.fromid?opt.fromid:'' 78 fromid:opt.fromid?opt.fromid:''
63 - })  
64 -  
65 - if (!res.data.openid) {//无预订人 79 + })
  80 + if (!res.data.openid) {//无预订人
66 url = '/pages/customer/detail_owner'; 81 url = '/pages/customer/detail_owner';
67 - } else { 82 + } else {
68 url = '/pages/customer/detail_customer'; 83 url = '/pages/customer/detail_customer';
69 if (res.data.openid == opt.openid) { 84 if (res.data.openid == opt.openid) {
70 - url = '/pages/customer/detail_owner'; 85 + url = '/pages/customer/detail_owner';
71 } 86 }
  87 + }
72 } 88 }
73 url+='?id='+res.data.id 89 url+='?id='+res.data.id
74 console.log('wx.redirectTo',url,res); 90 console.log('wx.redirectTo',url,res);
@@ -77,8 +93,15 @@ Page({ @@ -77,8 +93,15 @@ Page({
77 this.redirectTo({url: url}); 93 this.redirectTo({url: url});
78 }) 94 })
79 } else { 95 } else {
80 - console.log('url',url);  
81 - this.redirectTo({url: url}); 96 + if(this.enter_params && this.islove!='customer'){
  97 + //商户且未手动切换到顾客端
  98 + wx.reLaunch({
  99 + url:util.http_build_query(this.enter_params,'/pages/book/b_index')
  100 + })
  101 + return;
  102 + }
  103 + console.log('url',url);
  104 + this.redirectTo({url: url});
82 } 105 }
83 106
84 }, 107 },
@@ -149,12 +172,15 @@ Page({ @@ -149,12 +172,15 @@ Page({
149 enter_params=res.data; 172 enter_params=res.data;
150 } 173 }
151 if(enter_params) { 174 if(enter_params) {
152 - console.log('seller_enter_params', enter_params)  
153 - wx.reLaunch({  
154 - url:util.http_build_query(enter_params,'/pages/book/b_index')  
155 - })  
156 - return true 175 + return enter_params;
157 } 176 }
  177 + // if(enter_params) {
  178 + // console.log('seller_enter_params', enter_params)
  179 + // wx.reLaunch({
  180 + // url:util.http_build_query(enter_params,'/pages/book/b_index')
  181 + // })
  182 + // return true
  183 + // }
158 return false 184 return false
159 } 185 }
160 }) 186 })
1 // pages/me/index.js 1 // pages/me/index.js
  2 +import App from '../../utils/api';
  3 +import util from '../../utils/util'
  4 +const {regeneratorRuntime} = global
2 Page({ 5 Page({
3 6
4 /** 7 /**
5 * 页面的初始数据 8 * 页面的初始数据
6 */ 9 */
7 data: { 10 data: {
8 - 11 + hasSellerBook:false,
9 }, 12 },
10 - 13 + enter_params:'',
11 /** 14 /**
12 * 生命周期函数--监听页面加载 15 * 生命周期函数--监听页面加载
13 */ 16 */
14 onLoad: function (options) { 17 onLoad: function (options) {
15 - 18 + App.Reserve.SellerForOpenid({openid:getApp().openid}).then(res=>{
  19 + this.enter_params=res.data;
  20 + this.setData({
  21 + hasSellerBook:res.data,
  22 + })
  23 + })
16 }, 24 },
17 25
18 /** 26 /**
@@ -43,24 +51,10 @@ Page({ @@ -43,24 +51,10 @@ Page({
43 51
44 }, 52 },
45 53
46 - /**  
47 - * 页面相关事件处理函数--监听用户下拉动作  
48 - */  
49 - onPullDownRefresh: function () {  
50 -  
51 - },  
52 -  
53 - /**  
54 - * 页面上拉触底事件的处理函数  
55 - */  
56 - onReachBottom: function () {  
57 -  
58 - },  
59 -  
60 - /**  
61 - * 用户点击右上角分享  
62 - */  
63 - onShareAppMessage: function () {  
64 - 54 + gotoSellerBook(){
  55 + util.cache('islove','book');
  56 + wx.reLaunch({
  57 + url:util.http_build_query(this.enter_params,'/pages/book/b_index')
  58 + })
65 } 59 }
66 }) 60 })
@@ -31,5 +31,13 @@ @@ -31,5 +31,13 @@
31 </view> 31 </view>
32 </view> 32 </view>
33 </formids> 33 </formids>
  34 + <formids bindclick="gotoSellerBook" wx:if="{{hasSellerBook}}">
  35 + <view class="item flex-lr">
  36 + <view class="left">切换到商户模式</view>
  37 + <view class="right">
  38 + <image src="http://qn.colorcun.com/custom/lite-yd/image/click.png"></image>
  39 + </view>
  40 + </view>
  41 + </formids>
34 </view> 42 </view>
35 </view> 43 </view>
@@ -30,7 +30,7 @@ @@ -30,7 +30,7 @@
30 "list": [] 30 "list": []
31 }, 31 },
32 "miniprogram": { 32 "miniprogram": {
33 - "current": 15, 33 + "current": 6,
34 "list": [ 34 "list": [
35 { 35 {
36 "id": 0, 36 "id": 0,