Commit cbde107e by 梁建民

Merge branch 'master' of http://119.23.72.7/shiyu/icsalesProgram

# Conflicts:
#	project.config.json
福利中心
parents 91f8503a 420c3544
......@@ -199,6 +199,7 @@ image {
.c-com {
color: #515559;
word-break: break-all
}
/**询报价列表**/
......
......@@ -103,7 +103,7 @@ Component({
roomType: false,
chatType: this.data.chatType,
success(id, serverMsgId) {
console.log('发送消息成功')
console.log('发送消息成功');
if (me.data.username.your == getApp().globalData.customerNum){//是客服就将客服加到接口的聊天列表里面
if (getApp().globalData.isAddCustomer){
......
// components/priceItem/priceItem.js
import {
judgeToken
judgeTokenNew
} from '../../utils/util.js';
Component({
/**
......@@ -19,8 +19,11 @@ Component({
xb: {
type: Number // 询报价类型 1询价 2报价
},
isClick:{//是否可以点击
type:String
isClick: {//是否可以点击
type: String
},
isDelete: {//是否显示多选框
type: Boolean
}
},
......@@ -35,7 +38,7 @@ Component({
* 组件的方法列表
*/
methods: {
emitevent: function(e) {
emitevent: function (e) {
let inquiryItemsId = e.currentTarget.dataset.inquiryitemsid;
let goodId = e.currentTarget.dataset.goodid;
let offerId = e.currentTarget.dataset.offerid;
......@@ -43,19 +46,24 @@ Component({
let type = e.currentTarget.dataset.type; //1代表询价 2代表报价 3代表商品
let priceType = e.currentTarget.dataset.pricetype;
let isClick = e.currentTarget.dataset.isclick;
if(isClick==='0'){
let userid = e.currentTarget.dataset.userid;
let storageUserid = wx.getStorageSync('user_id');
if (isClick === '0') {
return;
}
if (judgeToken(true)) {
if (judgeTokenNew()) {
if (priceType == 1) {
if (type == 1) {
//查看自己的询价(别人给自己报的价)
wx.navigateTo({
url: "/pages/list/xj/index?type=1&inquiryItemsId=" + inquiryItemsId
})
} else if (type == 2) {
//查看别人的询价(自己给别人报的价)
wx.navigateTo({
url: "/pages/list/xj/index?type=2&inquiryItemsId=" + inquiryItemsId + '&offerId=' + offerId
})
}
} else if (priceType == 2) { //搜索页面商品跳转
......@@ -63,25 +71,49 @@ Component({
url: "/pages/detail/good/index?goodId=" + goodId + '&type=2'
})
} else if (priceType == 3) {
if (type == 1) {
wx.navigateTo({
url: "/pages/list/xj/index?type=2&inquiryItemsId=" + inquiryItemsId
})
} else if (type == 2) {
if (userid == storageUserid){
//自己看自己的数据
wx.navigateTo({
url: "/pages/detail/xj/index?inquiryItemsId=" + inquiryItemsId + '&offerId=' + offerId
url: "/pages/list/xj/index?type=1&inquiryItemsId=" + inquiryItemsId
})
}else{
//自己看别人的数据
if (type == 1) {
wx.navigateTo({
url: "/pages/list/xj/index?type=2&inquiryItemsId=" + inquiryItemsId
})
} else if (type == 2) {
wx.navigateTo({
url: "/pages/detail/xj/index?inquiryItemsId=" + inquiryItemsId + '&offerId=' + offerId
})
}
}
} else if (priceType == 4) {
} else if (priceType == 5) { //tab页商品跳转
} else if (priceType == 5) { //个人主页商品跳转
wx.navigateTo({
url: "/pages/detail/good/index?goodId=" + goodId + '&type=1'
})
} else if (priceType == 6) {//tab页商品跳转
if (this.data.isDelete) {
let index = e.currentTarget.dataset.index;
let data = {
index: index,
isdelete: this.data.priceList[index].isdelete,
goodId: goodId
}
//触发删除的自定义事件,逻辑在父组件中处理
this.triggerEvent('delete', data);
} else {
wx.navigateTo({
url: "/pages/detail/good/index?goodId=" + goodId + '&type=1'
})
}
}
}
},
previewImage: function(e) {
previewImage: function (e) {
let img = e.currentTarget.dataset.image;
wx.previewImage({
urls: [img]
......
......@@ -76,7 +76,7 @@
</block>
<!-- 搜索页面询报价展示 -->
<block wx:if="{{priceType==3}}">
<view class="price-item" wx:for="{{priceList}}" wx:key="{{index}}" catchtap="emitevent" data-inquiryitemsid="{{item['inquiry_items_id']}}" data-offerid="{{item['offer_id']}} " data-type="{{xb}}" data-pricetype="3" data-isclick="{{isClick}}">
<view class="price-item" wx:for="{{priceList}}" wx:key="{{index}}" catchtap="emitevent" data-inquiryitemsid="{{item['inquiry_items_id']}}" data-offerid="{{item['offer_id']}} " data-type="{{xb}}" data-pricetype="3" data-isclick="{{isClick}}" data-userid="{{item['user_id']}}">
<view class="item-header px-hr-bottom row verCenter bothSide nowrap">
<view class="row verCenter">
<text class="mark xun" wx:if="{{xb==1}}">询价</text>
......@@ -143,8 +143,35 @@
<text class="address ellipsis">备注:{{item.remark||'--'}}</text>
</view>
</view>
</block>
<!-- 商品管理 -->
</block>
<!-- 商品tab页 -->
<block wx:if="{{priceType == 6}}">
<view class="price-item good-item row verCenter" wx:for="{{priceList}}" wx:key="{{index}}" catchtap="emitevent" data-goodid="{{item.goods_id}}" data-pricetype="6" data-index="{{index}}">
<view class="check-view" wx:if="{{isDelete}}">
<image src="{{item.isdelete?'/res/images/imgs/gx-icon.png':'/res/images/imgs/wgx-icon.png'}}"></image>
</view>
<view class="check-item ellipsis">
<view class="item-header row verCenter bothSide nowrap good-header">
<view class="row verCenter">
<text class="name ellipsis good-name">{{item.goods_name}}</text>
<block wx:if="{{item.goods_images}}">
<text class="icon iconfont iconiconxiantiaoshouji14 good-icon" catchtap="previewImage" data-image="{{item.goods_images}}"></text>
</block>
</view>
<text class="price">
<block wx:if="{{item.currency == 1}}">¥{{item.price}}</block>
<block wx:else>${{item.price}}</block>
</text>
</view>
<view class="item-middle row verCenter nowrap">
<text class="brand ellipsis"><text>品牌:</text>{{item.brand_name}}</text>
<text class="num"><text>库存:</text>{{item.stock}} PCS</text>
</view>
</view>
</view>
</block>
<!-- 主页商品浏览 -->
<block wx:if="{{priceType == 5}}">
<view class="price-item good-item" wx:for="{{priceList}}" wx:key="{{index}}" catchtap="emitevent" data-goodid="{{item.goods_id}}" data-pricetype="5">
<view class="item-header row verCenter bothSide nowrap good-header">
......@@ -165,4 +192,5 @@
</view>
</view>
</block>
</block>
\ No newline at end of file
......@@ -100,3 +100,14 @@
color: #adb6bf;
font-size: 22rpx;
}
.check-view{
flex:0 0 70rpx;
}
.check-item{
flex:1;
}
.check-view image{
height:46rpx;
width:46rpx;
}
......@@ -20,7 +20,8 @@ Page({
currency: 0,
isClick: true,
isShowTip: true,
array: ['RMB','USD']
array: ['RMB','USD'],
date:"",
},
bindPickerChange: function (e) {
this.setData({
......@@ -30,10 +31,10 @@ Page({
formSubmit: function(e) {
let obj = e.detail.value;
if (!obj.goods_name.trim().length) {
tips('请填写型号');
tips('请填写商品型号');
return
} else if (obj.goods_name.trim().length < 3) {
tips('型号不能小于3个字符');
tips('商品型号不能小于3个字符');
return
} else if (!obj.brand_name.trim().length) {
tips('请填写品牌');
......@@ -45,7 +46,7 @@ Page({
tips('请填写数量');
return
} else if (isNaN(Number(obj.number.trim()))) {
tips('数量必须为数字');
tips('需求数量必须为数字');
return
} else {
if (!fourPoint(obj.price)) {
......@@ -53,10 +54,10 @@ Page({
}
if (obj.hq == 2) { //期货
if (!obj.day.trim().length) {
tips('请填写货期');
tips('请填写时间');
return
} else if (obj.day.trim().length>6){
tips('货期不能大于6个字符');
tips('时间不能大于6个字符');
return
}
}
......@@ -170,5 +171,10 @@ Page({
this.setData({
isShowTip: false
})
},
bindDateChange:function(e){
this.setData({
date: e.detail.value
})
}
})
\ No newline at end of file
<!--pages/form/xj/index.wxml-->
<view class="form-view">
<view class="form-view-xj">
<view class="tip row bothSide verCenter {{isShowTip?'':'noheight'}}">
<view class="tip-left row verCenter">
<text class="icon iconfont iconiconxiantiaoshouji12 tip-icon"></text>
......@@ -20,41 +20,41 @@
</view>
<form bindsubmit="formSubmit">
<view class="form-item row verCenter">
<text class="form-item-title">*型号</text>
<text class="form-item-title form-item-title-135">*商品型号</text>
<view class="form-item-right">
<input placeholder="请输入产品型号(必填)" placeholder-class="placeholderClass" type="text" name="goods_name"></input>
</view>
</view>
<view class="form-item row verCenter px-hr-top">
<text class="form-item-title">*品牌</text>
<text class="form-item-title form-item-title-135">*品牌</text>
<view class="form-item-right">
<input placeholder="请输入品牌(必填)" placeholder-class="placeholderClass" type="text" name="brand_name"></input>
</view>
</view>
<view class="form-item row verCenter px-hr-top">
<text class="form-item-title"> 封装</text>
<text class="form-item-title form-item-title-135"> 封装</text>
<view class="form-item-right">
<input placeholder="请输入封装" placeholder-class="placeholderClass" type="text" name="encap"></input>
</view>
</view>
<view class="form-item row verCenter px-hr-top">
<text class="form-item-title">*数量</text>
<text class="form-item-title form-item-title-135">*需求数量</text>
<view class="form-item-right">
<input placeholder="请输入数量(必填)" placeholder-class="placeholderClass" type="number" name="number"></input>
</view>
</view>
<view class="form-item row verCenter px-hr-top bj-item">
<text class="form-item-title">*价格</text>
<text class="form-item-title form-item-title-135">*接受价</text>
<view class="form-item-right row verCenter bothSide">
<input placeholder="请输入单价" placeholder-class="placeholderClass" type="digit" name="price"></input>
<picker class="price-type" value="{{currency}}" range="{{array}}" bindchange="bindPickerChange">
<picker class="price-type" value="{{currency}}" range="{{array}}" bindchange="bindPickerChange">
<text class="price-value">{{array[currency]}}</text>
<text class="icon iconfont iconbianzu1"></text>
</picker>
</picker>
</view>
</view>
<view class="form-item row verCenter px-hr-top qx-item">
<text class="form-item-title">*货期</text>
<text class="form-item-title form-item-title-135">*货期需求</text>
<view class="form-item-right">
<radio-group name="hq" bindchange="radioChange">
<label>
......@@ -67,14 +67,26 @@
</view>
</view>
<view class="form-item row verCenter px-hr-top" hidden="{{!isShowTime}}">
<text class="form-item-title">*时间</text>
<text class="form-item-title form-item-title-135">*时间</text>
<view class="form-item-right">
<input placeholder="请输入货期时间(天)" placeholder-class="placeholderClass" type="text" name="day"></input>
</view>
</view>
<!-- <view class="form-hr"></view>
<view class="form-item row verCenter">
<text class="form-item-title form-item-title-165">*询价有效期</text>
<picker mode="date" value="{{date}}" start="2015-09-01" bindchange="bindDateChange" class="form-item-right jz-item-right">
<text wx:if="{{date}}">{{date}}</text>
<block wx:else>
<text>请选择截止日期</text>
<image src="/res/images/icons/left-icon.png"></image>
</block>
</picker>
</view> -->
<view class="form-hr"></view>
<view class="form-item row px-hr-bottom">
<text class="form-item-title">备注</text>
<text class="form-item-title form-item-title-135">备注</text>
<view class="form-item-right">
<textarea placeholder="请输入备注" placeholder-class="placeholderClass" maxlength="-1" name="remark" />
</view>
......
/* pages/form/xj/index.wxss */
@import '/res/css/form.wxss'
\ No newline at end of file
@import '/res/css/form.wxss';
.form-view-xj .form-item-title-135 {
flex:0 0 135rpx;
text-align: left;
}
.form-view-xj .form-item-title-165 {
flex:0 0 165rpx;
text-align: left;
}
.form-view-xj .form-item-right{
padding: 0 24rpx 0 60rpx;
}
.jz-item-right{
text-align: right;
font-size:28rpx;
color:#8A9299;
}
.jz-item-right image{
width:16rpx;
height:27rpx;
vertical-align: middle;
margin-left:12rpx;
}
\ No newline at end of file
......@@ -95,6 +95,7 @@ Page({
wx.removeStorageSync('myPassword');
wx.removeStorageSync('auth');
wx.removeStorageSync('is_ShowModal')
wx.removeStorageSync('deleteGoodsData')
// wx.removeStorageSync('imNick');
wx.reLaunch({
url: '/pages/person/auth/index',
......
// pages/tab/good/good.js
import {
getData,
judgeToken
judgeTokenNew
} from '../../../utils/util.js';
import {
apis
......@@ -21,15 +21,22 @@ Page({
confirmKey: "",
isShowBottom: false,
isFixed: false,
isShowTip:true
isShowTip: true,
isdelete: false,
isCl: true,//是否已经擦亮了商品
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
onLoad: function (options) {
let me = this;
if (judgeToken(true)) {
wx.removeStorageSync('deleteGoodsData');
if (judgeTokenNew(() => {
wx.switchTab({
url: '/pages/tab/home/home'
});
},true)) {
this.getData();
};
getApp().globalData.bus.on('addGood', () => {
......@@ -53,12 +60,67 @@ Page({
}
})
},
bindKeyInput: function(e) {
//获取是否已经擦亮商品
getUserInfo: function () {
let token = wx.getStorageSync('access_token') || '';
let me = this;
getData(apis.userInfo, 'get', {
"token": token,
}, function (res) {
if (res.errcode == 0) {
if (res.data.polish_status == 2) {//未刷新
me.setData({
isCl: false
})
} else {//已刷新
me.setData({
isCl: true
})
}
}
}, false)
},
//擦亮商品
cLGoods: function () {
if (!this.data.isCl) {
this.cLGoodsAjax()
}
},
//擦亮商品的请求
cLGoodsAjax: function () {
let token = wx.getStorageSync('access_token');
let me = this;
getData(apis.polishAll, 'get', {
token: token,
}, function (res) {
if (res.errcode === 0) {
wx.showToast({
title: '擦亮成功',
icon: 'none',
duration: 2000
})
me.setData({
isCl: true
})
} else {
wx.showToast({
title: '擦亮失败',
icon: 'none',
duration: 2000
});
me.setData({
isCl: false
})
}
}, true)
},
bindKeyInput: function (e) {
this.setData({
key: e.detail.value
})
},
bindKeyConfirm: function() {
bindKeyConfirm: function () {
let key = this.data.key;
this.setData({
confirmKey: key,
......@@ -66,12 +128,14 @@ Page({
p: 1,
total: 0,
time: "",
isShowBottom: false
isShowBottom: false,
isdelete: false
});
wx.removeStorageSync('deleteGoodsData');
this.getData();
},
getData: function(isRefresh) {
getData: function (isRefresh) {
let me = this;
let token = wx.getStorageSync('access_token')
getData(apis.goodsInfo, 'get', {
......@@ -79,13 +143,14 @@ Page({
p: me.data.p,
token: token,
'goods_name/like': me.data.confirmKey
}, function(res) {
}, function (res) {
if (res.errcode === 0) {
let newArr = [];
if (me.data.p > 1) {
newArr = me.data.priceList;
}
for (let key in res.goods_list) {
res.goods_list[key].isdelete = false;
newArr.push(res.goods_list[key])
}
if (me.data.p == 1) {
......@@ -103,7 +168,8 @@ Page({
} else if (res.errcode === 110001 || res.errcode === 103001) {
if (me.data.p == 1) {
me.setData({
priceList: []
priceList: [],
total: 0
})
}
if (isRefresh) {
......@@ -117,10 +183,10 @@ Page({
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
onReady: function () {
},
onPageScroll: function(e) {
onPageScroll: function (e) {
if (e.scrollTop > 90) {
this.setData({
isFixed: true
......@@ -134,31 +200,40 @@ Page({
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
onShow: function () {
if (!judgeTokenNew(() => {
wx.switchTab({
url: '/pages/tab/home/home'
});
})) {
return;
}
this.getUserInfo();
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
onPullDownRefresh: function () {
wx.removeStorageSync('deleteGoodsData');
this.setData({
p: 1,
isShowBottom: false
isShowBottom: false,
isdelete: false
});
this.getData(true);
},
......@@ -166,7 +241,7 @@ Page({
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
onReachBottom: function () {
let allPage = Math.ceil(this.data.total / this.data.limit);
let p = this.data.p;
if (p == allPage) {
......@@ -181,14 +256,114 @@ Page({
this.getData();
}
},
closeTip:function(){
closeTip: function () {
this.setData({
isShowTip: false
});
},
fbGood: function() {
fbGood: function () {
wx.navigateTo({
url: "/pages/form/good/index",
})
},
editGoods: function () {
this.setData({
isdelete: true,
})
},
cancelGoods: function () {
this.setData({
isdelete: false,
});
let deleteGoodsData = wx.getStorageSync('deleteGoodsData') || [];
if (deleteGoodsData.length) {
for (let i = 0; i < this.data.priceList.length; i++) {
let index = deleteGoodsData.indexOf(this.data.priceList[i].goods_id);
if (index !== -1) {
let temp = 'priceList[' + i + '].isdelete';
this.setData({
[temp]: false
})
}
}
}
wx.removeStorageSync('deleteGoodsData');
},
deleteGoods: function () {
let deleteGoodsData = wx.getStorageSync('deleteGoodsData') || [];
let me = this;
if (!deleteGoodsData.length) {
return
}
wx.showModal({
title: '提示',
content: '是否确认删除当前选中的商品?',
confirmText: '取消',
confirmColor: "#0D84D1",
cancelText: "删除",
cancelColor: "#000000",
success(res) {
if (res.cancel) {
me.deleteGoodsAjax(deleteGoodsData)
}
}
})
},
//调用删除商品的接口
deleteGoodsAjax: function (data) {
let token = wx.getStorageSync('access_token');
let me = this;
getData(apis.goodsDelete, 'get', {
token: token,
'goods_id': JSON.stringify(data)
}, function (res) {
if (res.errcode === 0) {
wx.showToast({
title: '删除成功',
icon: 'none',
duration: 2000,
success: function () {
setTimeout(function () {
me.setData({
p: 1,
isShowBottom: false,
isdelete: false
})
me.getData();
wx.removeStorageSync('deleteGoodsData');
}, 1000)
}
})
} else {
wx.showToast({
title: '删除失败',
icon: 'none',
duration: 2000
})
}
}, true)
},
//子组件触发自定义的删除事件
onDelete: function (e) {
let index = e.detail.index;
let isdelete = e.detail.isdelete;
let goodId = e.detail.goodId
let deleteGoodsData = wx.getStorageSync('deleteGoodsData') || [];
let temp = 'priceList[' + index + '].isdelete'
this.setData({
[temp]: !isdelete
})
if (!isdelete) {
//选中
deleteGoodsData.push(goodId)
} else {
//取消
let i = deleteGoodsData.indexOf(goodId);
deleteGoodsData.splice(i, 1);
}
wx.setStorageSync('deleteGoodsData', deleteGoodsData)
}
})
\ No newline at end of file
......@@ -32,7 +32,7 @@
<text>新增商品</text>
</view>
</view>
<priceItem price-list="{{priceList}}" wx:if="{{priceList&&priceList.length!==0}}" price-type="5"></priceItem>
<priceItem price-list="{{priceList}}" wx:if="{{priceList&&priceList.length!==0}}" price-type="6" is-delete="{{isdelete}}" bind:delete="onDelete"></priceItem>
<view class="data-bottom row verCenter rowCenter" wx:if="{{isShowBottom}}">
<text class="line"></text>
<text class="text">我是有底线的</text>
......@@ -40,14 +40,22 @@
</view>
</view>
<view class="good-btn-div" wx:if="{{priceList&&priceList.length!==0}}">
<view class="good-btn-div" wx:if="{{(priceList&&priceList.length!==0) || isdelete}}">
<view class="btn-com btn-com-b add-good-btn" bindtap="fbGood">
<text class="icon iconfont iconiconxiantiaoshouji15"></text>
<text>新增商品</text>
</view>
</view>
<!-- <view class="cl-good">
<view class="cl-good {{isCl?'disabled':'allow'}}" wx:if="{{priceList&&priceList.length!==0}}" catchtap="cLGoods">
<view>擦亮</view>
<view>商品</view>
</view> -->
</view>
<view class="bj-good" catchtap="editGoods" wx:if="{{priceList&&priceList.length!==0}}">
<view>编辑</view>
<view>商品</view>
</view>
<view class="good-btn-div row rowCenter" wx:if="{{isdelete}}">
<view class="btn-com cancel-btn" catchtap="cancelGoods">取消</view>
<view class="btn-com btn-com-b delete-btn" catchtap="deleteGoods">删除</view>
</view>
</view>
\ No newline at end of file
......@@ -73,19 +73,40 @@
.nodata .add-good-btn {
margin-top: 40rpx;
}
.cl-good{
.cl-good,.bj-good{
position: fixed;
height:88rpx;
width:88rpx;
border-radius: 50%;
opacity: .8;
background-color: #EAAD37;
z-index: 99;
font-size: 24rpx;
color:#fff;
right:24rpx;
bottom:150rpx;
bottom:180rpx;
text-align: center;
padding-top:12rpx;
box-sizing:border-box;
}
.cl-good.allow{
background-color: #EAAD37;
}
.cl-good.disabled{
background-color: #DAE1E7;
}
.bj-good{
background-color: #0D84D1;
bottom:300rpx;
}
.good-btn-div .cancel-btn,.good-btn-div .delete-btn{
box-sizing: border-box;
width:339rpx;
margin:0;
}
.good-btn-div .cancel-btn{
border:2rpx solid rgba(216,223,230,1);
background-color: #fff;
color:#686E73;
margin-right:24rpx;
line-height:94rpx;
}
// pages/tab/home/home.js
import {
getData,
judgeToken,
judgeTokenNew,
interval
} from '../../../utils/util.js';
import {
......@@ -202,21 +202,21 @@ Page({
})
},
toWelfare: function () {
if (judgeToken(true)) {
if (judgeTokenNew()) {
wx.navigateTo({
url: "/pages/person/welfare/index"
})
}
},
toXj: function () {
if (judgeToken(true)) {
if (judgeTokenNew()) {
wx.navigateTo({
url: "/pages/form/xj/index"
})
}
},
fbGood: function () {
if (judgeToken(true)) {
if (judgeTokenNew()) {
wx.navigateTo({
url: "/pages/form/good/index",
})
......@@ -230,7 +230,7 @@ Page({
// }
},
toPrice:function(){
if (judgeToken(true)) {
if (judgeTokenNew()) {
wx.navigateTo({
url: "/pages/tab/price/price"
})
......
......@@ -26,9 +26,7 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if (!http.judgeToken(true)) {
return;
}
},
/**
......@@ -42,7 +40,13 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function () {
if (!http.judgeTokenNew(() => {
wx.switchTab({
url: '/pages/tab/home/home'
});
})) {
return;
}
//获取数量统计
http.getData(apis.countBusiness, 'GET', {
token: wx.getStorageSync('access_token')
......@@ -153,7 +157,7 @@ Page({
name: getApp().globalData.customerName,
name1: companyName,
id: userId,
touserid: '',
touserid: getApp().globalData.customerUserId,
title: getApp().globalData.customerName,
img: '',
img1: avatar
......
......@@ -2,7 +2,7 @@
let disp = require("../../../utils/broadcast");
// let WebIM = require("../../../utils/WebIM")["default"];
import {
judgeToken,
judgeTokenNew,
getData,
interval,
matchReg,
......@@ -31,7 +31,11 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if (judgeToken(true)) {
if (judgeTokenNew(() => {
wx.switchTab({
url: '/pages/tab/home/home'
});
}, true)) {
let me = this;
let my = wx.getStorageSync("myUsername");
//监听未读消息数
......@@ -153,6 +157,13 @@ Page({
*/
onShow: function () {
if (!judgeTokenNew(() => {
wx.switchTab({
url: '/pages/tab/home/home'
});
})) {
return;
}
let my = wx.getStorageSync("myUsername");
let token = wx.getStorageSync('access_token') || '';
let isShowModal = wx.getStorageSync('is_ShowModal')||''
......
......@@ -52,7 +52,7 @@
"list": []
},
"miniprogram": {
"current": 30,
"current": 55,
"list": [
{
"id": -1,
......@@ -420,29 +420,29 @@
},
{
"id": -1,
"name": "pages/person/certification/addcertification/index",
"pathName": "pages/person/certification/addcertification/index",
"name": "pages/tab/good/good",
"pathName": "pages/tab/good/good",
"query": "",
"scene": null
},
{
"id": -1,
"name": "pages/tab/me/me",
"pathName": "pages/tab/me/me",
"name": "pages/form/xj/index",
"pathName": "pages/form/xj/index",
"query": "",
"scene": null
},
{
"id": -1,
"name": "pages/person/welfare/index",
"pathName": "pages/person/welfare/index",
"name": "pages/tab/home/home",
"pathName": "pages/tab/home/home",
"query": "",
"scene": null
},
{
"id": -1,
"name": "pages/person/withdrawal/index",
"pathName": "pages/person/withdrawal/index",
"name": "pages/tab/good/good",
"pathName": "pages/tab/good/good",
"scene": null
}
]
......
const auth_url = 'https://authapi.icsales.com';
const so_url = 'https://soapi.icsales.com';
const offer_url = "https://offerapi.icsales.com";
const user_url = 'https://userapi.icsales.com';
const goods_url = 'https://goodsapi.icsales.com';
const home_url = 'https://home.icsales.com';
const welfare_url = 'https://welfareapi.icsales.com'
// const auth_url = 'http://authapi.icsales.cc';
// const so_url = 'http://soapi.icsales.cc';
// const offer_url = "http://offerapi.icsales.cc";
// const user_url = 'http://userapi.icsales.cc';
// const goods_url = 'http://goodsapi.icsales.cc';
// const home_url = 'http://home.icsales.cc';
// const welfare_url = 'http://welfareapi.icsales.cc';
// const auth_url = 'https://authapi.icsales.com';
// const so_url = 'https://soapi.icsales.com';
// const offer_url = "https://offerapi.icsales.com";
// const user_url = 'https://userapi.icsales.com';
// const goods_url = 'https://goodsapi.icsales.com';
// const home_url = 'https://home.icsales.com';
// const welfare_url = 'https://welfareapi.icsales.com'
const auth_url = 'http://authapi.icsales.cc';
const so_url = 'http://soapi.icsales.cc';
const offer_url = "http://offerapi.icsales.cc";
const user_url = 'http://userapi.icsales.cc';
const goods_url = 'http://goodsapi.icsales.cc';
const home_url = 'http://home.icsales.cc';
const welfare_url = 'http://welfareapi.icsales.cc';
const apis = {
......@@ -335,7 +335,15 @@ const apis = {
/**
* 确认兑换接口
*/
userExchangesConfirm: welfare_url + '/user_exchanges/exchange/confirm'
userExchangesConfirm: welfare_url + '/user_exchanges/exchange/confirm',
/**
* 批量删除商品
*/
goodsDelete: goods_url + '/goods/delete',
/**
* 擦亮全部商品
*/
polishAll: goods_url + '/goods/polish/all'
}
......
......@@ -49,7 +49,6 @@ const getImUser = () => {
}else{
avatar = res.data.avatar
}
console.log(res)
wx.setStorageSync('avatar', avatar);
wx.setStorageSync('company_name', res.data.company_name || '');
wx.setStorageSync("myUsername", res.data.im_username);
......
......@@ -4,7 +4,7 @@ const getData = (url, type, param, callBack, loading, isheader, istoken) => {
wx.showNavigationBarLoading();
var token, header, tokenInvalid;
var token, header;
//获取token
token = wx.getStorageSync('access_token');
......@@ -23,7 +23,9 @@ const getData = (url, type, param, callBack, loading, isheader, istoken) => {
//是否启用loading加载效果
if (loading) {
wx.showLoading();
wx.showLoading({
mask:true
});
}
//是否启用请求头token
......@@ -37,7 +39,33 @@ const getData = (url, type, param, callBack, loading, isheader, istoken) => {
"Content-Type": "applciation/json"
}
}
wx.getNetworkType({
success(res) {
const networkType = res.networkType;
if (networkType !='none'){
//有网络
axios(url, type, params, callBack, loading, header)
}else{
wx.hideNavigationBarLoading();
if (loading) {
wx.hideLoading();
}
wx.showToast({
title: '网络出现异常',
icon: 'none',
duration: 2000
});
}
},
fail:function(){
axios(url, type, params, callBack, loading, header)
}
})
};
const axios = (url, type, params, callBack, loading, header) => {
let tokenInvalid;
wx.request({
url: url,
data: params,
......@@ -78,6 +106,7 @@ const getData = (url, type, param, callBack, loading, isheader, istoken) => {
wx.removeStorageSync('myPassword');
wx.removeStorageSync('auth');
wx.removeStorageSync('is_ShowModal');
wx.removeStorageSync('deleteGoodsData');
WebIM.conn.close();
// wx.removeStorageSync('imNick');
wx.reLaunch({
......@@ -102,7 +131,6 @@ const getData = (url, type, param, callBack, loading, isheader, istoken) => {
}
})
};
//上传文件
const uploadFile = (url, path, callBack) => {
wx.showLoading({
......@@ -301,6 +329,31 @@ const judgeToken = (boolen) => {
return false;
}
};
//判断token是否存在的新的逻辑
const judgeTokenNew = (cancelFun,modalHide) => {
let token = wx.getStorageSync('access_token');
if (token) {
return true
} else {
if(!modalHide){
wx.showModal({
title: '提示',
content: '亲,请登录体验更多功能',
confirmText: '登录',
success(res) {
if (res.confirm) {
wx.reLaunch({
url: '/pages/person/auth/index'
});
} else if (res.cancel) {
cancelFun && cancelFun()
}
}
})
}
return false;
}
};
const interval = (usedTime) => {
let days = Math.floor(usedTime / (24 * 3600 * 1000));
//计算出小时数
......@@ -376,5 +429,6 @@ module.exports = {
interval: interval,
matchReg: matchReg,
reloginIm: reloginIm,
fourPoint: fourPoint
fourPoint: fourPoint,
judgeTokenNew: judgeTokenNew
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment