Commit 952c943077d308f53f16a5d21eb2da9d3f4fa062

Authored by vking
1 parent b353d836

启动页

// pages/customer/index.js
var mta=require('mta-wechat-analysis')
var mta = require('mta-wechat-analysis')
import App from '../../utils/api';
import util from '../../utils/util'
const {regeneratorRuntime} = global
Page({
/**
* 页面的初始数据
*/
data: {
loadHidden:false,
},
/**
* 生命周期函数--监听页面加载
*/
islove:'',//用户在哪端
enter_params:'',//商户入口参数
isInvitation:false,//客户经理
async onLoad(opt) {
console.log('onLoad', opt,mta);
//转化场景值到opt
this.selectComponent("#network").debug(opt, 'opt');
if (opt.scene) {//扫码进入
let query = decodeURIComponent(opt.scene);
query.split('&').forEach(q => {
let _q = q.split('=');
opt[_q[0]] = _q[1];
})
this.selectComponent("#network").debug(opt, 'scene');
}
if(opt.act=='tobook'){//消息跳入运营处理预订
delete opt.act
return this.redirectTo({url: util.http_build_query(opt,'/pack-book/pages/book/b_index')});
}
mta.Page.init({
"appID":"500667280",
"eventID":"500667287",
"statPullDownFresh":true,
"statShareApp":true,
"statReachBottom":true,
"lauchOpts":opt, //渠道分析
/**
* 页面的初始数据
*/
data: {
loadHidden: false,
},
/**
* 生命周期函数--监听页面加载
*/
islove: '',//用户在哪端
enter_params: '',//商户入口参数
isInvitation: false,//客户经理
async onLoad(opt) {
console.log('onLoad', opt, mta);
//转化场景值到opt
this.selectComponent("#network").debug(opt, 'opt');
if (opt.scene) {//扫码进入
let query = decodeURIComponent(opt.scene);
query.split('&').forEach(q => {
let _q = q.split('=');
opt[_q[0]] = _q[1];
})
this.selectComponent("#network").debug(opt, 'scene');
}
if (opt.act == 'tobook') {//消息跳入运营处理预订
delete opt.act
return this.redirectTo({url: util.http_build_query(opt, '/pack-book/pages/book/b_index')});
}
mta.Page.init({
"appID": "500667280",
"eventID": "500667287",
"statPullDownFresh": true,
"statShareApp": true,
"statReachBottom": true,
"lauchOpts": opt, //渠道分析
});
opt.openid = await this.getOpenid();
if (!opt.openid) {
console.log('App.Orders.CheckOrder no openid');
this.selectComponent("#network").refresh();
return;
}
if (opt.islove) {
util.cache('islove', opt.islove);
this.islove = opt.islove
} else {
this.islove = await util.cache('islove')
}
this.usi = {data: {seller: {}, invitation: {}}}
try {
this.usi = await App.Invitation.UserIdentity({openid: opt.openid});
} catch (e) {
console.log('App.Invitation.UserIdentity no usi');
}
this.options = opt
setTimeout(() => {
this.initRun();
}, 3000)
},
async initRun() {
let opt = this.options
let usi=this.usi
if (usi.data.seller.flag) {//商户
//获得商户数据
//this.enter_params=await this.SellerForOpenid(opt.openid);
this.enter_params = usi.data.data;
}
if (usi.data.invitation.flag) {//已是客户经理
this.isInvitation = true;
}
//console.log('this.enter_params',this.enter_params)
let url = '/pages/reserve/index';
if (opt.id > 0 || opt.sms_code) {
if (opt.invite_name) {
let invite_names = wx.getStorageSync('invite_names') || {};
invite_names[opt.id] = opt.invite_name;
wx.setStorage({
key: 'invite_names',
data: invite_names
});
opt.openid = await this.getOpenid();
if (!opt.openid) {
console.log('App.Orders.CheckOrder no openid');
this.selectComponent("#network").refresh();
return;
}
if(opt.islove){
util.cache('islove',opt.islove);
this.islove=opt.islove
}else{
this.islove=await util.cache('islove')
}
let usi={data:{seller:{},invitation:{}}}
try{
usi=await App.Invitation.UserIdentity({openid:opt.openid});
}catch (e){
console.log('App.Invitation.UserIdentity no usi');
}
if(usi.data.seller.flag){//商户
//获得商户数据
//this.enter_params=await this.SellerForOpenid(opt.openid);
this.enter_params=usi.data.data;
}
if(usi.data.invitation.flag){//已是客户经理
this.isInvitation=true;
}
let param = {
openid: opt.openid,
}
if (opt.sms_code) {
param.code = opt.sms_code;
} else {
param.rid = opt.id
}
App.Reserve.Detail(param).then(res => {
console.log(res.data.note_openid, this.enter_params.seller_openid)
if (this.enter_params) {//商户
//if(res.data.sid==this.enter_params.seller_id && opt.hasSellerShare==1){//不是客户端分享,且是同一个店的
if (res.data.note_openid == this.enter_params.seller_openid && opt.hasSellerShare == 1) {//不是客户端分享,且是记录人
util.cache('enter_params', this.enter_params)
//url = '/pages/book/b_detail';
url = '/pack-book/pages/book/b_invitation';
}
}
//console.log('this.enter_params',this.enter_params)
let url = '/pages/reserve/index';
if (opt.id > 0 || opt.sms_code) {
if(opt.invite_name){
let invite_names=wx.getStorageSync('invite_names') ||{};
invite_names[opt.id]=opt.invite_name;
wx.setStorage({
key:'invite_names',
data:invite_names
});
if (url != '/pack-book/pages/book/b_invitation') {
//设置关系
App.Reserve.SetRelaOpenid({
rid: res.data.id,
openid: opt.openid,
fromid: opt.fromid ? opt.fromid : ''
})
if (!res.data.openid) {//无预订人
url = '/pages/customer/detail_owner';
if (opt.hasInvitation == 1) {
url = '/pages/customer/detail_owner_invitation';
}
let param={
openid: opt.openid,
} else {
url = '/pages/customer/detail_customer';
if (opt.hasInvitation == 1) {
url = '/pages/customer/detail_invitation';
}
if(opt.sms_code){
param.code=opt.sms_code;
}else{
param.rid=opt.id
if (res.data.openid == opt.openid) {
url = '/pages/customer/detail_owner';
if (opt.hasInvitation == 1) {
url = '/pages/customer/detail_owner_invitation';
}
}
App.Reserve.Detail(param).then(res => {
console.log(res.data.note_openid,this.enter_params.seller_openid)
if(this.enter_params){//商户
//if(res.data.sid==this.enter_params.seller_id && opt.hasSellerShare==1){//不是客户端分享,且是同一个店的
if(res.data.note_openid==this.enter_params.seller_openid && opt.hasSellerShare==1){//不是客户端分享,且是记录人
util.cache('enter_params',this.enter_params)
//url = '/pages/book/b_detail';
url = '/pack-book/pages/book/b_invitation';
}
}
if(url!='/pack-book/pages/book/b_invitation'){
//设置关系
App.Reserve.SetRelaOpenid({
rid:res.data.id,
openid:opt.openid,
fromid:opt.fromid?opt.fromid:''
})
if (!res.data.openid) {//无预订人
url = '/pages/customer/detail_owner';
if(opt.hasInvitation==1){
url = '/pages/customer/detail_owner_invitation';
}
} else {
url = '/pages/customer/detail_customer';
if(opt.hasInvitation==1){
url = '/pages/customer/detail_invitation';
}
if (res.data.openid == opt.openid) {
url = '/pages/customer/detail_owner';
if(opt.hasInvitation==1){
url = '/pages/customer/detail_owner_invitation';
}
}
}
}
if(!opt.tplid || typeof opt.tplid=='undefined' || opt.tplid=='undefined'){
opt.tplid=1
}
url+='?id='+res.data.id+'&tplid='+opt.tplid
console.log('wx.redirectTo',url,res);
this.redirectTo({url: url});
}).catch(res=>{
this.redirectTo({url: url});
})
} else {
if(this.enter_params && this.islove!='customer' && this.islove!='invitation'){
//商户且未手动切换到顾客端或客户经理
wx.reLaunch({
url:util.http_build_query(this.enter_params,'/pack-book/pages/book/b_index')
})
return;
}
if(this.isInvitation && this.islove!='customer' && this.islove!='book'){
//客户经理且未手动切换到顾客端或商户
wx.reLaunch({
url:'/pages/manager-invitation/review'
})
return;
}
console.log('url',url);
this.redirectTo({url: url});
}
},
redirectTo(red){
console.log('this.redirectTo',red);
if(red.url.indexOf('list')>0 || red.url.indexOf('reserve/index')>0){
wx.switchTab(red);
}else{
wx.redirectTo(red);
if (!opt.tplid || typeof opt.tplid == 'undefined' || opt.tplid == 'undefined') {
opt.tplid = 1
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
async getOpenid(){
let openid = await getApp().getOpenid();
return openid;
},
async SellerForOpenid(openid){
let enter_params='';
let res=await App.Reserve.SellerForOpenid({openid:openid});
if(res.data && res.data.seller_id){
enter_params=res.data;
}
if(enter_params) {
return enter_params;
url += '?id=' + res.data.id + '&tplid=' + opt.tplid
console.log('wx.redirectTo', url, res);
this.redirectTo({url: url});
}).catch(res => {
this.redirectTo({url: url});
})
} else {
if (this.enter_params && this.islove != 'customer' && this.islove != 'invitation') {
//商户且未手动切换到顾客端或客户经理
wx.reLaunch({
url: util.http_build_query(this.enter_params, '/pack-book/pages/book/b_index')
})
return;
}
// if(enter_params) {
// console.log('seller_enter_params', enter_params)
// wx.reLaunch({
// url:util.http_build_query(enter_params,'/pages/book/b_index')
// })
// return true
// }
return false
},
networkEvent(e){
console.log('networkEvent',e.detail);
if(!e.detail.hasWork){
this.setData({
loadHidden:true,
if (this.isInvitation && this.islove != 'customer' && this.islove != 'book') {
//客户经理且未手动切换到顾客端或商户
wx.reLaunch({
url: '/pages/manager-invitation/review'
})
return;
}
console.log('url', url);
this.redirectTo({url: url});
}
},
redirectTo(red) {
console.log('this.redirectTo', red);
if (red.url.indexOf('list') > 0 || red.url.indexOf('reserve/index') > 0) {
wx.switchTab(red);
} else {
wx.redirectTo(red);
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
async getOpenid() {
let openid = await getApp().getOpenid();
return openid;
},
async SellerForOpenid(openid) {
let enter_params = '';
let res = await App.Reserve.SellerForOpenid({openid: openid});
if (res.data && res.data.seller_id) {
enter_params = res.data;
}
if (enter_params) {
return enter_params;
}
// if(enter_params) {
// console.log('seller_enter_params', enter_params)
// wx.reLaunch({
// url:util.http_build_query(enter_params,'/pages/book/b_index')
// })
// return true
// }
return false
},
networkEvent(e) {
console.log('networkEvent', e.detail);
if (!e.detail.hasWork) {
this.setData({
loadHidden: true,
})
}
},
})
\ No newline at end of file
... ...
<view class="page">
<loading hidden="{{loadHidden}}">数据加载中</loading>
<view class="page flex-vc">
<view class="zhuozi"></view>
<view class="qingke">请客订包间</view>
<view class="zhoudao">就用周到安排</view>
</view>
<network id="network" bindnetwork="networkEvent"></network>
\ No newline at end of file
... ...
/* pages/customer/index.wxss */
\ No newline at end of file
/* pages/customer/index.wxss */
page{
background:rgba(255,209,66,0.1);
}
.zhuozi{
width: 590rpx;
height: 400rpx;
background-size: 100% 100%;
background-image: url("http://nosqn.colorcun.com/qidong/zhuozi.png");
margin-top: 280rpx;
}
.qingke{
height:74rpx;
font-size:52rpx;
font-family:STSongti-SC-Black,STSongti-SC;
font-weight:900;
color:rgba(192,163,105,1);
line-height:74rpx;
letter-spacing:2rpx;
margin-top: 100rpx;
}
.zhoudao{
font-size:30rpx;
font-family:STSongti-SC-Regular,STSongti-SC;
font-weight:400;
color:rgba(192,163,105,1);
line-height:52rpx;
width:280rpx;
height:52rpx;
border-radius:26rpx;
border:2rpx solid rgba(192,163,105,1);
margin-top: 30rpx;
text-align: center;
}
\ No newline at end of file
... ...