Commit e28c0117 by 施宇

商品擦亮及无网络状态下显示提示

parent f57773da
......@@ -22,7 +22,8 @@ Page({
isShowBottom: false,
isFixed: false,
isShowTip: true,
isdelete: false
isdelete: false,
isCl: true,//是否已经擦亮了商品
},
/**
......@@ -55,6 +56,61 @@ Page({
}
})
},
//获取是否已经擦亮商品
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
......@@ -109,7 +165,7 @@ Page({
if (me.data.p == 1) {
me.setData({
priceList: [],
total:0
total: 0
})
}
if (isRefresh) {
......@@ -141,7 +197,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.getUserInfo()
},
/**
......@@ -252,7 +308,6 @@ Page({
'goods_id': JSON.stringify(data)
}, function (res) {
if (res.errcode === 0) {
//删除成功后手动将数据删除
wx.showToast({
title: '删除成功',
icon: 'none',
......@@ -266,7 +321,7 @@ Page({
})
me.getData();
wx.removeStorageSync('deleteGoodsData');
},1000)
}, 1000)
}
})
......
......@@ -46,7 +46,7 @@
<text>新增商品</text>
</view>
</view>
<view class="cl-good" wx:if="{{priceList&&priceList.length!==0}}">
<view class="cl-good {{isCl?'disabled':'allow'}}" wx:if="{{priceList&&priceList.length!==0}}" catchtap="cLGoods">
<view>擦亮</view>
<view>商品</view>
</view>
......
......@@ -79,7 +79,6 @@
width:88rpx;
border-radius: 50%;
opacity: .8;
background-color: #EAAD37;
z-index: 99;
font-size: 24rpx;
color:#fff;
......@@ -89,6 +88,12 @@
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;
......
......@@ -52,7 +52,7 @@
"list": []
},
"miniprogram": {
"current": 53,
"current": 55,
"list": [
{
"id": -1,
......@@ -429,6 +429,20 @@
"id": -1,
"name": "pages/form/xj/index",
"pathName": "pages/form/xj/index",
"query": "",
"scene": null
},
{
"id": -1,
"name": "pages/tab/home/home",
"pathName": "pages/tab/home/home",
"query": "",
"scene": null
},
{
"id": -1,
"name": "pages/tab/good/good",
"pathName": "pages/tab/good/good",
"scene": null
}
]
......
......@@ -339,7 +339,11 @@ const apis = {
/**
* 批量删除商品
*/
goodsDelete: goods_url + '/goods/delete'
goodsDelete: goods_url + '/goods/delete',
/**
* 擦亮全部商品
*/
polishAll: goods_url + '/goods/polish/all'
}
......
......@@ -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');
......@@ -39,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,
......@@ -105,7 +131,6 @@ const getData = (url, type, param, callBack, loading, isheader, istoken) => {
}
})
};
//上传文件
const uploadFile = (url, path, callBack) => {
wx.showLoading({
......
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