123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- // index.js
- var app = getApp();
- let host = app.globalData.servsers; // 请求的url
- Page({
- data: {
- userId : '',
- userInfo: {},
- phone:'',
- orderList:{
- label:'我的采购订单',
- summary:"全部",
- state:"0",
- icon:"icon-left",
- data:[
- {
- label:"待付款",
- state:"1",
- icon:"icon-icon-test",
- num:0,
- },
- {
- label: "待审核",
- state: "2",
- icon: "icon-daishenhe",
- num: 0,
- },
- {
- label: "待发货",
- state: "3",
- icon: "icon-daifahuo1",
- num: 0,
- },
- {
- label: "待收货",
- state: "4",
- icon: "icon-daishouhuo",
- num: 0,
- },
- {
- label: "已完成",
- state: "5",
- icon: "icon-yiwancheng1",
- num: 0,
- }
- ]
- },
- madeList: {
- label: '我的定制订单',
- summary: "全部",
- state: "",
- icon: "icon-left",
- data: [
- {
- label: "待付款",
- state: "0",
- icon: "icon-icon-test",
- num: 0,
- },
- {
- label: "待发货",
- state: "2",
- icon: "icon-daifahuo1",
- num: 0,
- },
- {
- label: "待收货",
- state: "3",
- icon: "icon-daishouhuo",
- num: 0,
- }
- ]
- },
- channelName:null, // 判断渠道是否登陆了,默认没有登陆
- },
- onLoad: function () {
- var that = this;
- var openid = getApp().globalData.openid;
- var un_id = getApp().globalData.un_id;
- var host = getApp().globalData.servsers;
-
- wx.showNavigationBarLoading();
- wx.request({
- url: host + "phoneapi/phoneall",
- data: {},
- method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
- header: {
- 'Accept': 'application/json'
- },
- success: function (res) {
- that.setData({
- phone: res.data.rows[0].phone,
- });
- if (res == null || res.data == null) {
- console.error('网络请求失败');
- return;
- }
- wx:wx.hideNavigationBarLoading(
- that.setData({
- hidden : ''
- })
- )
- }
- });
- that.setData({
- userInfo: getApp().globalData.userInfo,
- userId: getApp().globalData.un_id
- })
-
- console.log(getApp().globalData.userInfo)
-
- },
- //重新加载
- onShow: function () {
- var that = this;
- var host = getApp().globalData.servsers;
- var un_id = getApp().globalData.un_id;
- var openid = getApp().globalData.openid;
- var userInfo = getApp().globalData.userInfo;
- var userRole = getApp().globalData.userRole;
- that.getPhone(that)
- userInfo = getApp().globalData.userInfo;
-
- //查询用户身份
- // getApp().getUserRole(un_id);//获取用户角色
- // userRole = getApp().globalData.userRole;
- // }
- that.setData({
- userInfo: userInfo,
- userId: un_id,
- userRole: userRole,
- channelName: wx.getStorageSync('channelName') ? wx.getStorageSync('channelName') : null
- })
- },
- orderList(e){
- console.log(e,"orderList")
- let state = e.currentTarget.dataset.state
- wx.navigateTo({
- url: '/pages/orderList/orderList?state='+state,
- })
- },
- madeList(e) {
- let state = e.currentTarget.dataset.state;
- wx.navigateTo({
- url: '/customized/pages/order/order?state=' + state,
- })
- },
- bindPhone(){
- wx.navigateTo({
- url: '/pages/bindingPhone/bindingPhone',
- })
- },
- getPhone(that){
- console.log("获取手机号")
- wx.request({
- url:host+ '/userapi/userGetPhone',
- method:'get',
- data:{
- user_id: getApp().globalData.un_id
- },
- success(res){
- var tel = res.data.result
- tel = "" + tel;
- var reg = /(\d{3})\d{4}(\d{4})/;
- var tel1 = tel.replace(reg, "$1****$2")
- console.log(tel1)
- that.setData({
- 'userInfo.phone':res.data.result,
- tel:tel1
- })
- }
- })
- },
- outChann(){ // 退出渠道
- wx.removeStorageSync('channelIdObj');
- this.setData({
- channelName:null
- })
- wx.removeStorageSync('channelName')
- },
- channelInfo(){
- if (wx.getStorageSync('channelIdObj').channelAccountId){
- wx.navigateTo({
- url: '/pages/channelInfor/channelInfor',
- })
- } else {
- wx.navigateTo({
- url: '/pages/login/login?url=/pages/channelInfor/channelInfor',
- })
- }
-
- }
- })
|