Commit 72af175581a468863e48fb38a45bdfcae3cd3bbe

Authored by vking
1 parent 34ce49ec

编辑查看模式

@@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
2 import util from '../../../../utils/util'; 2 import util from '../../../../utils/util';
3 import App from '../../../../utils/api'; 3 import App from '../../../../utils/api';
4 const {regeneratorRuntime} = global 4 const {regeneratorRuntime} = global
  5 +import gl from '../../../global'
5 Component({ 6 Component({
6 /** 7 /**
7 * 组件的属性列表 8 * 组件的属性列表
@@ -44,6 +45,10 @@ Component({ @@ -44,6 +45,10 @@ Component({
44 * 组件的方法列表 45 * 组件的方法列表
45 */ 46 */
46 itemList:[], 47 itemList:[],
  48 + ready(){
  49 + this.hasEditorFlag=false;
  50 + this.hasEditor();
  51 + },
47 methods: { 52 methods: {
48 boardClick(){ 53 boardClick(){
49 if(!this.data.event) return; 54 if(!this.data.event) return;
@@ -76,27 +81,39 @@ Component({ @@ -76,27 +81,39 @@ Component({
76 //桌位操作 81 //桌位操作
77 boardOpt(){ 82 boardOpt(){
78 let itemList=[] 83 let itemList=[]
79 - if(!this.data.board.reserve_id && this.data.board.enable==1){  
80 - if(this.data.ddate){  
81 - let t=new Date()/1000;  
82 - //console.log('this.data.ddate.substr(11,10)',this.data.ddate.substr(11,10))  
83 - //if(parseInt(this.data.ddate.substr(11,10))>t){  
84 - itemList.push('订座')  
85 - //}  
86 - } 84 + if(this.hasEditorFlag){
87 85
  86 + if(!this.data.board.reserve_id && this.data.board.enable==1){
  87 + if(this.data.ddate){
  88 + let t=new Date()/1000;
  89 + //console.log('this.data.ddate.substr(11,10)',this.data.ddate.substr(11,10))
  90 + //if(parseInt(this.data.ddate.substr(11,10))>t){
  91 + itemList.push('订座')
  92 + //}
  93 + }
  94 +
  95 + }
  96 + if(this.data.board.reserve_id>0){
  97 + itemList.push('查看详情')
  98 + }
  99 + itemList.push(this.data.board.enable==1?'停用桌位':'启用桌位')
  100 + //console.log(getApp().system)
  101 + this.itemList=itemList;
  102 + this.setData({
  103 + itemList:itemList,
  104 + })
  105 + this.selectComponent('#boardas').show();
  106 + console.log('this.data.board',this.data.board)
  107 + }else{
  108 + if(this.data.board.reserve_id>0){
  109 + itemList.push('查看详情')
  110 + this.itemList=itemList;
  111 + this.setData({
  112 + itemList:itemList,
  113 + })
  114 + this.selectComponent('#boardas').show();
  115 + }
88 } 116 }
89 - if(this.data.board.reserve_id>0){  
90 - itemList.push('查看详情')  
91 - }  
92 - itemList.push(this.data.board.enable==1?'停用桌位':'启用桌位')  
93 - //console.log(getApp().system)  
94 - this.itemList=itemList;  
95 - this.setData({  
96 - itemList:itemList,  
97 - })  
98 - this.selectComponent('#boardas').show();  
99 - console.log('this.data.board',this.data.board)  
100 }, 117 },
101 //桌位选择 118 //桌位选择
102 boardChoose(){ 119 boardChoose(){
@@ -111,5 +128,11 @@ Component({ @@ -111,5 +128,11 @@ Component({
111 this.triggerEvent('boardEvent',{type:'boardEnable'}) 128 this.triggerEvent('boardEvent',{type:'boardEnable'})
112 }) 129 })
113 }, 130 },
  131 + //是否可以编辑
  132 + hasEditor(){
  133 + gl.getHasEditorFlag().then(()=>{
  134 + this.hasEditorFlag=true
  135 + }).catch(()=>{})
  136 + },
114 } 137 }
115 }) 138 })
1 // components/book/tabBar/tabBar.js 1 // components/book/tabBar/tabBar.js
2 import util from '../../../../utils/util' 2 import util from '../../../../utils/util'
3 import App from '../../../../utils/api'; 3 import App from '../../../../utils/api';
  4 +import gl from '../../../global'
4 const {regeneratorRuntime} = global 5 const {regeneratorRuntime} = global
5 Component({ 6 Component({
6 /** 7 /**
@@ -14,6 +15,7 @@ Component({ @@ -14,6 +15,7 @@ Component({
14 data: { 15 data: {
15 pi: 0, 16 pi: 0,
16 dot:0, 17 dot:0,
  18 + hasEditorFlag:false,
17 }, 19 },
18 attached(){ 20 attached(){
19 let pages = getCurrentPages(); 21 let pages = getCurrentPages();
@@ -31,6 +33,7 @@ Component({ @@ -31,6 +33,7 @@ Component({
31 }, 33 },
32 ready(){ 34 ready(){
33 this.hasDot() 35 this.hasDot()
  36 + this.hasEditor();
34 }, 37 },
35 /** 38 /**
36 * 组件的方法列表 39 * 组件的方法列表
@@ -54,6 +57,13 @@ Component({ @@ -54,6 +57,13 @@ Component({
54 }) 57 })
55 this.triggerEvent('NewCustomer',{total:dot}) 58 this.triggerEvent('NewCustomer',{total:dot})
56 }); 59 });
57 - } 60 + },
  61 + hasEditor(){
  62 + gl.getHasEditorFlag().then(()=>{
  63 + this.setData({
  64 + hasEditorFlag:true,
  65 + })
  66 + }).catch(()=>{})
  67 + },
58 } 68 }
59 }) 69 })
1 <!--components/book/tabBar/tabBar.wxml--> 1 <!--components/book/tabBar/tabBar.wxml-->
2 <view class="tabBar flex-cc"> 2 <view class="tabBar flex-cc">
3 - <formids class="item flex-vc" bindtap="redirectTo" data-url="/pack-book/pages/book/b_addnew"> 3 + <formids wx:if="{{hasEditorFlag}}" class="item flex-vc" bindtap="redirectTo" data-url="/pack-book/pages/book/b_addnew">
4 <view class="flex-vc {{pi==0?'checked':''}}" > 4 <view class="flex-vc {{pi==0?'checked':''}}" >
5 <view class="icon reserve"></view> 5 <view class="icon reserve"></view>
6 <view class="text">订座</view> 6 <view class="text">订座</view>
  1 +import App from '../utils/api'
  2 +import util from '../utils/util'
  3 +const {regeneratorRuntime} = global
  4 +module.exports ={
  5 + getHasEditorFlag(){
  6 + return new Promise(async function(success,fail){
  7 + let enter_params=util.cache('enter_params');
  8 + let res=await App.Reserve.SellerInfo(enter_params)
  9 + if(res.data.config.is_auth==1){
  10 + success()
  11 + }else{
  12 + fail()
  13 + }
  14 + })
  15 + },
  16 +}
1 var util = require('../../../utils/util.js') 1 var util = require('../../../utils/util.js')
2 -var uri=require('../../../utils/uri.js') 2 +var uri = require('../../../utils/uri.js')
3 import App from '../../../utils/api'; 3 import App from '../../../utils/api';
  4 +
4 const {regeneratorRuntime} = global 5 const {regeneratorRuntime} = global
5 import TP from '../../../utils/tpls'; 6 import TP from '../../../utils/tpls';
  7 +import gl from '../../global';
  8 +
6 Page({ 9 Page({
7 - data:{  
8 - actionSheetHidden:true,  
9 - actionSheetItems:['客户取消','客户行程改变']  
10 - },  
11 - sc:{},  
12 - tpls:TP.tpls(),  
13 - enter_params:{},  
14 - onLoad:async function (opt) {  
15 - util.setBarTitle('预订详情');  
16 - console.log(opt)  
17 - this.getDetail(opt.id);  
18 - wx.showShareMenu({  
19 - withShareTicket: true,  
20 - success:function(res){  
21 - console.log(res)  
22 - }  
23 - })  
24 - this.enter_params=util.cache('enter_params');  
25 - this.sc=(await App.Reserve.SellerInfo(this.enter_params)).data;  
26 - console.log('this.sc',this.sc);  
27 - this.chooseManagerInit();  
28 - },  
29 - onShow:function(){  
30 - this.notice=this.selectComponent('#notice');  
31 - },  
32 - noticeCall:function(){  
33 - this.selectComponent('#notice').show();  
34 - },  
35 - onShareAppMessage: function () {  
36 - this.selectComponent('#notice').close();  
37 - var obj=this.data.bookInfo;  
38 - let path=util.http_build_query({  
39 - id:this.data.bookInfo.id,  
40 - fromid:getApp().openid,  
41 - hasSellerShare:1,  
42 - hasInvitation:1,  
43 - tplid:1  
44 - },'/pages/customer/index')  
45 - return {  
46 - //title: (nickname||'')+'给你发送了一个订座信息,点击查看详情',  
47 - title: this.tpls[0].shareFirstTitle,  
48 - path: path,  
49 - imageUrl:this.tpls[0].shareFirstImage,  
50 - success: function (res) {  
51 - console.log(res,666666)  
52 - },  
53 - fail:function(){  
54 - console.log('ccccc')  
55 - },  
56 - complete:function(){  
57 - console.log('ccccc')  
58 - }  
59 - };  
60 - },  
61 - getcall:function(){  
62 - if(!this.detailData.hasOwner){  
63 - return util.toast('只有记录人可以拨打','none'); 10 + data: {
  11 + actionSheetHidden: true,
  12 + actionSheetItems: ['客户取消', '客户行程改变'],
  13 + hasEditorFlag: false,
  14 + },
  15 + sc: {},
  16 + tpls: TP.tpls(),
  17 + enter_params: {},
  18 + onLoad: async function (opt) {
  19 + util.setBarTitle('预订详情');
  20 + console.log(opt)
  21 + this.getDetail(opt.id);
  22 + wx.showShareMenu({
  23 + withShareTicket: true,
  24 + success: function (res) {
  25 + console.log(res)
64 } 26 }
65 - if(this.data.bookInfo.phone.length<3){  
66 - return util.toast('号码错误','none'); 27 + })
  28 + this.enter_params = util.cache('enter_params');
  29 + this.sc = (await App.Reserve.SellerInfo(this.enter_params)).data;
  30 + console.log('this.sc', this.sc);
  31 + this.chooseManagerInit();
  32 + },
  33 + onShow: function () {
  34 + this.notice = this.selectComponent('#notice');
  35 + gl.getHasEditorFlag().then(() => {
  36 + this.setData({
  37 + hasEditorFlag: true,
  38 + })
  39 + }).catch(()=>{})
  40 + },
  41 + noticeCall: function () {
  42 + this.selectComponent('#notice').show();
  43 + },
  44 + onShareAppMessage: function () {
  45 + this.selectComponent('#notice').close();
  46 + var obj = this.data.bookInfo;
  47 + let path = util.http_build_query({
  48 + id: this.data.bookInfo.id,
  49 + fromid: getApp().openid,
  50 + hasSellerShare: 1,
  51 + hasInvitation: 1,
  52 + tplid: 1
  53 + }, '/pages/customer/index')
  54 + return {
  55 + //title: (nickname||'')+'给你发送了一个订座信息,点击查看详情',
  56 + title: this.tpls[0].shareFirstTitle,
  57 + path: path,
  58 + imageUrl: this.tpls[0].shareFirstImage,
  59 + success: function (res) {
  60 + console.log(res, 666666)
  61 + },
  62 + fail: function () {
  63 + console.log('ccccc')
  64 + },
  65 + complete: function () {
  66 + console.log('ccccc')
67 } 67 }
68 - wx.makePhoneCall({  
69 - phoneNumber: this.data.bookInfo.phone, //仅为示例,并非真实的电话号码  
70 - complete:()=>{  
71 - this.selectComponent('#notice').close();  
72 - } 68 + };
  69 + },
  70 + getcall: function () {
  71 + if (!this.detailData.hasOwner) {
  72 + return util.toast('只有记录人可以拨打', 'none');
  73 + }
  74 + if (this.data.bookInfo.phone.length < 3) {
  75 + return util.toast('号码错误', 'none');
  76 + }
  77 + wx.makePhoneCall({
  78 + phoneNumber: this.data.bookInfo.phone, //仅为示例,并非真实的电话号码
  79 + complete: () => {
  80 + this.selectComponent('#notice').close();
  81 + }
  82 + })
  83 + },
  84 + chooseManagerInit() {
  85 + try {
  86 + let managers = this.sc.manager;
  87 + let mans = [];
  88 + let mans_role = [];
  89 + // let space='';
  90 + // for(let i=0;i<50;i++){
  91 + // space+=' ';
  92 + // }
  93 + if (managers.length > 0) {
  94 + managers.forEach(man => {
  95 + let nickname = man.nick_name || man.user_name;
  96 + mans.push(nickname);
  97 + //mans_role.push('     ['+man.role_name+'] -- '+man.user_name+space);
  98 + mans_role.push('[' + man.role_name + '] -- ' + nickname);
73 }) 99 })
74 - },  
75 - chooseManagerInit(){  
76 - try{  
77 - let managers=this.sc.manager;  
78 - let mans=[];  
79 - let mans_role=[];  
80 - // let space='';  
81 - // for(let i=0;i<50;i++){  
82 - // space+=' ';  
83 - // }  
84 - if(managers.length>0){  
85 - managers.forEach(man=>{  
86 - let nickname=man.nick_name||man.user_name;  
87 - mans.push(nickname);  
88 - //mans_role.push('     ['+man.role_name+'] -- '+man.user_name+space);  
89 - mans_role.push('['+man.role_name+'] -- '+nickname);  
90 - })  
91 - }  
92 - this.setData({mans:mans,mans_role:mans_role})  
93 - }catch(e){  
94 - wx.showToast({  
95 - title:'无客户经理',  
96 - icon:'none'  
97 - });  
98 - }  
99 - },  
100 - chooseManager(e){  
101 - let mansIndex=util.val(e);  
102 - this.setData({mansIndex:mansIndex});  
103 - try{  
104 - let managers=this.sc.manager;  
105 - let man=managers[mansIndex];  
106 - if(man){  
107 - App.Reserve.SetReserveCusman({  
108 - rid:this.data.bookInfo.id,  
109 - cusman_id:man.id,  
110 - cusman:man.nick_name||man.user_name,  
111 - cusman_phone:man.user_phone?man.user_phone:'',  
112 - cusman_account:man.user_wechat?man.user_wechat:'',  
113 - cusman_openid:man.seat_openid?man.seat_openid:''  
114 - }).then(()=>{  
115 - this.getDetail(this.data.bookInfo.id,true);  
116 - });  
117 - }  
118 - }catch(e){  
119 - console.log(e);  
120 - }  
121 -  
122 - },  
123 - flushSellerInfo(){  
124 - App.Reserve.SellerInfo(util.cache('enter_params'),true);  
125 - },  
126 - detailData:null,  
127 - async getDetail(id,force=false){  
128 - let res=await App.Reserve.Detail({rid:id,openid:''},force);  
129 - res.data.rdateStr=util.unixtoTime(res.data.ddate,"MM月DD日 HH:II")  
130 - res.data.phoneStr=res.data.phone||'';  
131 - let enter_params=util.cache('enter_params');  
132 - let sc=(await App.Reserve.SellerInfo(enter_params)).data  
133 - let note_openid=enter_params.seller_openid;  
134 - res.data.hasOwner=false;  
135 - if(note_openid==res.data.note_openid || sc.seller_user.role_name=='管理员'){  
136 - res.data.hasOwner=true;  
137 - }  
138 - if(!res.data.hasOwner){  
139 - res.data.phoneStr=res.data.phoneStr.replace(/(\d{2})(.{5})(\d{3})/,function($0,$1,$2,$3){  
140 - return $1+'**'+$3;  
141 - })  
142 - }  
143 - if(res.data.status==4 && res.data.cancel){  
144 - res.data.cancel.cdateStr=util.unixtoTime(res.data.cancel.cdate,"YYYY.MM.DD HH:II")  
145 } 100 }
146 - this.detailData=res.data; 101 + this.setData({mans: mans, mans_role: mans_role})
  102 + } catch (e) {
  103 + wx.showToast({
  104 + title: '无客户经理',
  105 + icon: 'none'
  106 + });
  107 + }
  108 + },
  109 + chooseManager(e) {
  110 + let mansIndex = util.val(e);
  111 + this.setData({mansIndex: mansIndex});
  112 + try {
  113 + let managers = this.sc.manager;
  114 + let man = managers[mansIndex];
  115 + if (man) {
  116 + App.Reserve.SetReserveCusman({
  117 + rid: this.data.bookInfo.id,
  118 + cusman_id: man.id,
  119 + cusman: man.nick_name || man.user_name,
  120 + cusman_phone: man.user_phone ? man.user_phone : '',
  121 + cusman_account: man.user_wechat ? man.user_wechat : '',
  122 + cusman_openid: man.seat_openid ? man.seat_openid : ''
  123 + }).then(() => {
  124 + this.getDetail(this.data.bookInfo.id, true);
  125 + });
  126 + }
  127 + } catch (e) {
  128 + console.log(e);
  129 + }
147 130
148 - this.setData({  
149 - tables:res.data.tables,  
150 - bookInfo:res.data,  
151 - })  
152 - },  
153 - gotoModify(){  
154 - wx.redirectTo({  
155 - url:'./b_addnew?id='+this.data.bookInfo.id  
156 - })  
157 - },  
158 - cancelReserve(){ 131 + },
  132 + flushSellerInfo() {
  133 + App.Reserve.SellerInfo(util.cache('enter_params'), true);
  134 + },
  135 + detailData: null,
  136 + async getDetail(id, force = false) {
  137 + let res = await App.Reserve.Detail({rid: id, openid: ''}, force);
  138 + res.data.rdateStr = util.unixtoTime(res.data.ddate, "MM月DD日 HH:II")
  139 + res.data.phoneStr = res.data.phone || '';
  140 + let enter_params = util.cache('enter_params');
  141 + let sc = (await App.Reserve.SellerInfo(enter_params)).data
  142 + let note_openid = enter_params.seller_openid;
  143 + res.data.hasOwner = false;
  144 + if (note_openid == res.data.note_openid || sc.seller_user.role_name == '管理员') {
  145 + res.data.hasOwner = true;
  146 + }
  147 + if (!res.data.hasOwner) {
  148 + res.data.phoneStr = res.data.phoneStr.replace(/(\d{2})(.{5})(\d{3})/, function ($0, $1, $2, $3) {
  149 + return $1 + '**' + $3;
  150 + })
  151 + }
  152 + if (res.data.status == 4 && res.data.cancel) {
  153 + res.data.cancel.cdateStr = util.unixtoTime(res.data.cancel.cdate, "YYYY.MM.DD HH:II")
  154 + }
  155 + this.detailData = res.data;
  156 +
  157 + this.setData({
  158 + tables: res.data.tables,
  159 + bookInfo: res.data,
  160 + })
  161 + },
  162 + gotoModify() {
  163 + wx.redirectTo({
  164 + url: './b_addnew?id=' + this.data.bookInfo.id
  165 + })
  166 + },
  167 + cancelReserve() {
159 this.selectComponent('#cancel').show(); 168 this.selectComponent('#cancel').show();
160 }, 169 },
161 - reserveCancel(e){  
162 - console.log('reserveCancel',e.detail);  
163 - this.getDetail(this.data.bookInfo.id,true); 170 + reserveCancel(e) {
  171 + console.log('reserveCancel', e.detail);
  172 + this.getDetail(this.data.bookInfo.id, true);
164 }, 173 },
165 - actionSheetChange(e){ 174 + actionSheetChange(e) {
166 this.setData({ 175 this.setData({
167 - actionSheetHidden:true 176 + actionSheetHidden: true
168 }) 177 })
169 }, 178 },
170 - async startDinner(e){  
171 - let cause={};  
172 - let enter_params=util.cache('enter_params');  
173 - let sc=(await App.Reserve.SellerInfo(enter_params)).data  
174 - cause={desc:""}  
175 - if(enter_params){  
176 - cause.uid=enter_params.manager_id; 179 + async startDinner(e) {
  180 + let cause = {};
  181 + let enter_params = util.cache('enter_params');
  182 + let sc = (await App.Reserve.SellerInfo(enter_params)).data
  183 + cause = {desc: ""}
  184 + if (enter_params) {
  185 + cause.uid = enter_params.manager_id;
177 } 186 }
178 - if(sc.seller_user){  
179 - cause.uname=(sc.seller_user.nick_name||sc.seller_user.nickname) 187 + if (sc.seller_user) {
  188 + cause.uname = (sc.seller_user.nick_name || sc.seller_user.nickname)
180 } 189 }
181 App.Reserve.SetReserveStatus({ 190 App.Reserve.SetReserveStatus({
182 - rid:this.data.bookInfo.id,  
183 - status:util.attr(e,'status'),  
184 - cause:JSON.stringify(cause),  
185 - }).then(()=>{  
186 - this.getDetail(this.data.bookInfo.id,true); 191 + rid: this.data.bookInfo.id,
  192 + status: util.attr(e, 'status'),
  193 + cause: JSON.stringify(cause),
  194 + }).then(() => {
  195 + this.getDetail(this.data.bookInfo.id, true);
187 }); 196 });
188 }, 197 },
189 - showOrder(){ 198 + showOrder() {
190 wx.navigateTo({ 199 wx.navigateTo({
191 - url:util.http_build_query({rid:this.data.bookInfo.id,oid:this.data.bookInfo.orderid,identity:2},'/pack-cookbook/pages/success') 200 + url: util.http_build_query({
  201 + rid: this.data.bookInfo.id,
  202 + oid: this.data.bookInfo.orderid,
  203 + identity: 2
  204 + }, '/pack-cookbook/pages/success')
192 }); 205 });
193 }, 206 },
194 }) 207 })
@@ -43,12 +43,17 @@ @@ -43,12 +43,17 @@
43 <view class="order-info"> 43 <view class="order-info">
44 <view class="flex-lr order-detail"> 44 <view class="flex-lr order-detail">
45 <view class="gray-deep-font font30r">客户经理</view> 45 <view class="gray-deep-font font30r">客户经理</view>
46 - <view class="flex-lr black-font font34r" style=" border-bottom: 2rpx solid #999;">  
47 - <picker bindchange="chooseManager" catchtap="flushSellerInfo" value="{{mansIndex}}" range="{{mans_role}}">  
48 - <view class="picker"> 46 + <view class="flex-lr black-font font34r">
  47 + <picker bindchange="chooseManager" catchtap="flushSellerInfo"
  48 + wx:if="{{hasEditorFlag}}"
  49 + value="{{mansIndex}}" range="{{mans_role}}">
  50 + <view class="picker" style="border-bottom:2rpx solid #999;">
49 {{mans[mansIndex]?mans[mansIndex]:bookInfo.cusman?bookInfo.cusman:'请选择'}} 51 {{mans[mansIndex]?mans[mansIndex]:bookInfo.cusman?bookInfo.cusman:'请选择'}}
50 </view> 52 </view>
51 </picker> 53 </picker>
  54 + <view class="picker" wx:else="">
  55 + {{mans[mansIndex]?mans[mansIndex]:bookInfo.cusman?bookInfo.cusman:'无'}}
  56 + </view>
52 </view> 57 </view>
53 </view> 58 </view>
54 <view class="flex-lr order-detail"> 59 <view class="flex-lr order-detail">
@@ -85,7 +90,7 @@ @@ -85,7 +90,7 @@
85 <formids bindclick="showOrder">查看菜品</formids> 90 <formids bindclick="showOrder">查看菜品</formids>
86 </view> 91 </view>
87 </view> 92 </view>
88 - <view class="notice-button-border font34r flex-lr"> 93 + <view class="notice-button-border font34r flex-lr" wx:if="{{hasEditorFlag}}">
89 <view> 94 <view>
90 <formids bindclick="gotoModify">变更预订</formids> 95 <formids bindclick="gotoModify">变更预订</formids>
91 </view> 96 </view>