Commit 5ec36300 by wangyalan-git

登录修改

parent 05cdd109
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="749f7826-d70b-49cf-994d-3acd7b934330" name="Default Changelist" comment=""> <list default="true" id="749f7826-d70b-49cf-994d-3acd7b934330" name="Default Changelist" comment="" />
<change beforePath="$PROJECT_DIR$/images/icon/poster1@2x.png" beforeDir="false" afterPath="$PROJECT_DIR$/images/icon/poster1@2x.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pages/index/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/pages/index/index.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pages/index/index.wxml" beforeDir="false" afterPath="$PROJECT_DIR$/pages/index/index.wxml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pages/index/index.wxss" beforeDir="false" afterPath="$PROJECT_DIR$/pages/index/index.wxss" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pages/login/login.wxss" beforeDir="false" afterPath="$PROJECT_DIR$/pages/login/login.wxss" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pages/newDetail/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/pages/newDetail/index.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pages/newDetail/index.json" beforeDir="false" afterPath="$PROJECT_DIR$/pages/newDetail/index.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pages/newDetail/index.wxml" beforeDir="false" afterPath="$PROJECT_DIR$/pages/newDetail/index.wxml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pages/newDetail/index.wxss" beforeDir="false" afterPath="$PROJECT_DIR$/pages/newDetail/index.wxss" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pages/newsList/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/pages/newsList/index.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pages/newsList/index.wxml" beforeDir="false" afterPath="$PROJECT_DIR$/pages/newsList/index.wxml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pages/newsList/index.wxss" beforeDir="false" afterPath="$PROJECT_DIR$/pages/newsList/index.wxss" afterDir="false" />
<change beforePath="$PROJECT_DIR$/project.config.json" beforeDir="false" afterPath="$PROJECT_DIR$/project.config.json" afterDir="false" />
</list>
<ignored path="$PROJECT_DIR$/.tmp/" /> <ignored path="$PROJECT_DIR$/.tmp/" />
<ignored path="$PROJECT_DIR$/temp/" /> <ignored path="$PROJECT_DIR$/temp/" />
<ignored path="$PROJECT_DIR$/tmp/" /> <ignored path="$PROJECT_DIR$/tmp/" />
...@@ -25,6 +11,19 @@ ...@@ -25,6 +11,19 @@
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" /> <option name="LAST_RESOLUTION" value="IGNORE" />
</component> </component>
<component name="FileEditorManager">
<leaf>
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/utils/config.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="88">
<caret line="4" lean-forward="true" selection-start-line="4" selection-end-line="4" />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="Git.Settings"> <component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component> </component>
...@@ -39,6 +38,7 @@ ...@@ -39,6 +38,7 @@
<foldersAlwaysOnTop value="true" /> <foldersAlwaysOnTop value="true" />
</navigator> </navigator>
<panes> <panes>
<pane id="Scope" />
<pane id="ProjectPane"> <pane id="ProjectPane">
<subPane> <subPane>
<expand> <expand>
...@@ -50,7 +50,6 @@ ...@@ -50,7 +50,6 @@
<select /> <select />
</subPane> </subPane>
</pane> </pane>
<pane id="Scope" />
</panes> </panes>
</component> </component>
<component name="PropertiesComponent"> <component name="PropertiesComponent">
...@@ -84,11 +83,12 @@ ...@@ -84,11 +83,12 @@
<updated>1603358883438</updated> <updated>1603358883438</updated>
<workItem from="1603358884856" duration="655000" /> <workItem from="1603358884856" duration="655000" />
<workItem from="1604054385788" duration="4000" /> <workItem from="1604054385788" duration="4000" />
<workItem from="1604972001520" duration="6000" />
</task> </task>
<servers /> <servers />
</component> </component>
<component name="TimeTrackingManager"> <component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="659000" /> <option name="totallyTimeSpent" value="665000" />
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="-7" y="-7" width="1550" height="838" extended-state="6" /> <frame x="-7" y="-7" width="1550" height="838" extended-state="6" />
...@@ -116,4 +116,13 @@ ...@@ -116,4 +116,13 @@
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" /> <option name="version" value="1" />
</component> </component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/utils/config.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="88">
<caret line="4" lean-forward="true" selection-start-line="4" selection-end-line="4" />
</state>
</provider>
</entry>
</component>
</project> </project>
\ No newline at end of file
...@@ -12,6 +12,18 @@ App({ ...@@ -12,6 +12,18 @@ App({
this.globalData.shareCode = wx.getStorageSync('shareCode') this.globalData.shareCode = wx.getStorageSync('shareCode')
} }
}, },
tipGoLogin: function () {
const that = this
wx.showModal({
title: '前往登录',
content: '请先登录后操作',
success: function (res) {
if (res.confirm) {
that.goLogin()
}
}
})
},
goLogin: function () { goLogin: function () {
console.log("登录") console.log("登录")
wx.navigateTo({ wx.navigateTo({
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
var http = require("../../utils/http.js"); var http = require("../../utils/http.js");
// var config = require("../../utils/config.js"); // var config = require("../../utils/config.js");
const Big = require("../../utils/big.min.js"); const Big = require("../../utils/big.min.js");
const app = getApp()
Page({ Page({
...@@ -35,6 +36,9 @@ Page({ ...@@ -35,6 +36,9 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { onShow: function () {
let token = wx.getStorageSync('token') ? true : false
if (token) {
wx.showLoading(); wx.showLoading();
//加载购物车 //加载购物车
var params = { var params = {
...@@ -66,9 +70,10 @@ Page({ ...@@ -66,9 +70,10 @@ Page({
} }
}; };
http.request(params); http.request(params);
http.getCartCount();//重新计算购物车总数量 http.getCartCount();//重新计算购物车总数量
} else {
app.tipGoLogin()
}
}, },
/** /**
...@@ -153,7 +158,7 @@ Page({ ...@@ -153,7 +158,7 @@ Page({
break; break;
} }
} }
if(flag){ if (flag) {
break; break;
} }
} }
......
...@@ -57,11 +57,12 @@ Page({ ...@@ -57,11 +57,12 @@ Page({
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function(options) { onLoad: function (options) {
let token = wx.getStorageSync('token') ? true : false
this.setData({ this.setData({
prodId: options.prodid, prodId: options.prodid,
}); });
if (token) {
// 加载商品信息 // 加载商品信息
this.getProdInfo(); this.getProdInfo();
// 加载评论数据 // 加载评论数据
...@@ -70,6 +71,9 @@ Page({ ...@@ -70,6 +71,9 @@ Page({
this.getLittleProdComm(); this.getLittleProdComm();
// 查看用户是否关注 // 查看用户是否关注
this.getCollection(); this.getCollection();
} else {
app.tipGoLogin()
}
}, },
/** /**
...@@ -240,7 +244,7 @@ Page({ ...@@ -240,7 +244,7 @@ Page({
/** /**
* 根据skuList进行数据组装 * 根据skuList进行数据组装
*/ */
groupSkuProp: function() { groupSkuProp: function () {
var skuList = this.data.skuList; var skuList = this.data.skuList;
//当后台返回只有一个SKU时,且SKU属性值为空时,即该商品没有规格选项,该SKU直接作为默认选中SKU //当后台返回只有一个SKU时,且SKU属性值为空时,即该商品没有规格选项,该SKU直接作为默认选中SKU
...@@ -307,7 +311,7 @@ Page({ ...@@ -307,7 +311,7 @@ Page({
}, },
//将已选的 {key:val,key2:val2}转换成 [val,val2] //将已选的 {key:val,key2:val2}转换成 [val,val2]
parseSelectedObjToVals: function() { parseSelectedObjToVals: function () {
var selectedPropObj = this.data.selectedPropObj; var selectedPropObj = this.data.selectedPropObj;
var selectedProperties = ""; var selectedProperties = "";
var selectedProp = []; var selectedProp = [];
...@@ -336,7 +340,7 @@ Page({ ...@@ -336,7 +340,7 @@ Page({
}, },
//点击选择规格 //点击选择规格
toChooseItem: function(e) { toChooseItem: function (e) {
var val = e.currentTarget.dataset.val; var val = e.currentTarget.dataset.val;
var key = e.currentTarget.dataset.key; var key = e.currentTarget.dataset.key;
var selectedPropObj = this.data.selectedPropObj; var selectedPropObj = this.data.selectedPropObj;
...@@ -348,7 +352,7 @@ Page({ ...@@ -348,7 +352,7 @@ Page({
}, },
//判断数组是否包含某对象 //判断数组是否包含某对象
array_contain: function(array, obj) { array_contain: function (array, obj) {
for (var i = 0; i < array.length; i++) { for (var i = 0; i < array.length; i++) {
if (array[i] == obj) //如果要求数据类型也一致,这里可使用恒等号=== if (array[i] == obj) //如果要求数据类型也一致,这里可使用恒等号===
return true; return true;
...@@ -359,14 +363,14 @@ Page({ ...@@ -359,14 +363,14 @@ Page({
/** /**
* 生命周期函数--监听页面初次渲染完成 * 生命周期函数--监听页面初次渲染完成
*/ */
onReady: function() { onReady: function () {
}, },
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function() { onShow: function () {
this.setData({ this.setData({
totalCartNum: app.globalData.totalCartCount totalCartNum: app.globalData.totalCartCount
}); });
...@@ -375,35 +379,35 @@ Page({ ...@@ -375,35 +379,35 @@ Page({
/** /**
* 生命周期函数--监听页面隐藏 * 生命周期函数--监听页面隐藏
*/ */
onHide: function() { onHide: function () {
}, },
/** /**
* 生命周期函数--监听页面卸载 * 生命周期函数--监听页面卸载
*/ */
onUnload: function() { onUnload: function () {
}, },
/** /**
* 页面相关事件处理函数--监听用户下拉动作 * 页面相关事件处理函数--监听用户下拉动作
*/ */
onPullDownRefresh: function() { onPullDownRefresh: function () {
}, },
/** /**
* 页面上拉触底事件的处理函数 * 页面上拉触底事件的处理函数
*/ */
onReachBottom: function() { onReachBottom: function () {
}, },
/** /**
* 用户点击右上角分享 * 用户点击右上角分享
*/ */
onShareAppMessage: function() { onShareAppMessage: function () {
// return { // return {
// title: "商品详情分享", // title: "商品详情分享",
// path:`/pages/prod/prod` // path:`/pages/prod/prod`
...@@ -413,7 +417,7 @@ Page({ ...@@ -413,7 +417,7 @@ Page({
/** /**
* 跳转到首页 * 跳转到首页
*/ */
toHomePage: function() { toHomePage: function () {
wx.switchTab({ wx.switchTab({
url: '/pages/index/index', url: '/pages/index/index',
}) })
...@@ -422,7 +426,7 @@ Page({ ...@@ -422,7 +426,7 @@ Page({
/** /**
* 跳转到购物车 * 跳转到购物车
*/ */
toCartPage: function() { toCartPage: function () {
wx.switchTab({ wx.switchTab({
url: '/pages/basket/basket', url: '/pages/basket/basket',
}) })
...@@ -431,14 +435,16 @@ Page({ ...@@ -431,14 +435,16 @@ Page({
/** /**
* 加入购物车 * 加入购物车
*/ */
addToCart: function(event) { addToCart: function (event) {
let token = wx.getStorageSync('token') ? true : false
if (!token) {
app.tipGoLogin()
return
}
if (!this.data.findSku) { if (!this.data.findSku) {
return; return;
} }
var ths = this; var ths = this;
wx.showLoading({
mask: true
});
var params = { var params = {
url: "/p/shopCart/changeItem", url: "/p/shopCart/changeItem",
method: "POST", method: "POST",
...@@ -449,7 +455,7 @@ Page({ ...@@ -449,7 +455,7 @@ Page({
shopId: this.data.shopId, shopId: this.data.shopId,
skuId: this.data.defaultSku.skuId skuId: this.data.defaultSku.skuId
}, },
callBack: function(res) { callBack: function (res) {
//console.log(res); //console.log(res);
ths.setData({ ths.setData({
totalCartNum: ths.data.totalCartNum + ths.data.prodNum totalCartNum: ths.data.totalCartNum + ths.data.prodNum
...@@ -467,7 +473,12 @@ Page({ ...@@ -467,7 +473,12 @@ Page({
/** /**
* 立即购买 * 立即购买
*/ */
buyNow: function() { buyNow: function () {
let token = wx.getStorageSync('token') ? true : false
if (!token) {
app.tipGoLogin()
return
}
if (!this.data.findSku) { if (!this.data.findSku) {
return; return;
} }
...@@ -486,7 +497,7 @@ Page({ ...@@ -486,7 +497,7 @@ Page({
/** /**
* 减数量 * 减数量
*/ */
onCountMinus: function() { onCountMinus: function () {
var prodNum = this.data.prodNum; var prodNum = this.data.prodNum;
if (prodNum > 1) { if (prodNum > 1) {
this.setData({ this.setData({
...@@ -498,7 +509,7 @@ Page({ ...@@ -498,7 +509,7 @@ Page({
/** /**
* 加数量 * 加数量
*/ */
onCountPlus: function() { onCountPlus: function () {
var prodNum = this.data.prodNum; var prodNum = this.data.prodNum;
if (prodNum < 1000) { if (prodNum < 1000) {
this.setData({ this.setData({
...@@ -510,14 +521,14 @@ Page({ ...@@ -510,14 +521,14 @@ Page({
/** /**
* 分享设置 * 分享设置
*/ */
onShareAppMessage: function(res) { onShareAppMessage: function (res) {
return { return {
title: this.data.prodName, title: this.data.prodName,
path: '/pages/prod/prod?prodid=' + this.data.prodid path: '/pages/prod/prod?prodid=' + this.data.prodid
} }
}, },
showPopup: function() { showPopup: function () {
if (this.data.loadCouponIds) { if (this.data.loadCouponIds) {
this.setData({ this.setData({
popupShow: true popupShow: true
...@@ -559,18 +570,18 @@ Page({ ...@@ -559,18 +570,18 @@ Page({
} }
}) })
}, },
showSku: function() { showSku: function () {
this.setData({ this.setData({
skuShow: true skuShow: true
}); });
}, },
showComment: function() { showComment: function () {
this.setData({ this.setData({
commentShow: true commentShow: true
}); });
}, },
closePopup: function() { closePopup: function () {
this.setData({ this.setData({
popupShow: false, popupShow: false,
skuShow: false, skuShow: false,
......
...@@ -65,7 +65,8 @@ Page({ ...@@ -65,7 +65,8 @@ Page({
//加载订单数字 //加载订单数字
var ths = this; var ths = this;
// var status = ths.data.status // var status = ths.data.status
wx.showLoading();
if (this.data.isLogin) {
var params = { var params = {
url: "/p/myOrder/orderCount", url: "/p/myOrder/orderCount",
method: "GET", method: "GET",
...@@ -80,6 +81,9 @@ Page({ ...@@ -80,6 +81,9 @@ Page({
http.request(params); http.request(params);
this.getUserAccount() this.getUserAccount()
this.getPageInfo() this.getPageInfo()
} else {
app.tipGoLogin()
}
}, },
/** /**
......
...@@ -21,7 +21,7 @@ function request(params, isGetTonken) { ...@@ -21,7 +21,7 @@ function request(params, isGetTonken) {
dataType: 'json', dataType: 'json',
responseType: params.responseType == undefined ? 'text' : params.responseType, responseType: params.responseType == undefined ? 'text' : params.responseType,
success: function (res) { success: function (res) {
console.log('res',res) console.log('res', res)
wx.hideLoading() wx.hideLoading()
if (res.statusCode == 200) { if (res.statusCode == 200) {
console.log(res.data.code) console.log(res.data.code)
...@@ -33,7 +33,7 @@ function request(params, isGetTonken) { ...@@ -33,7 +33,7 @@ function request(params, isGetTonken) {
} else { } else {
if (params.errCallBack) { if (params.errCallBack) {
params.errCallBack(res); params.errCallBack(res);
}else { } else {
wx.showToast({ wx.showToast({
title: res.data.note, title: res.data.note,
icon: "none" icon: "none"
...@@ -53,6 +53,7 @@ function request(params, isGetTonken) { ...@@ -53,6 +53,7 @@ function request(params, isGetTonken) {
// if (!globalData.isLanding) { // if (!globalData.isLanding) {
globalData.isLanding = true globalData.isLanding = true
//重新获取token,再次请求接口 //重新获取token,再次请求接口
getApp().tipGoLogin()
// getApp().goLogin() // getApp().goLogin()
// } // }
} else if (res.statusCode == 400) { } else if (res.statusCode == 400) {
...@@ -72,7 +73,7 @@ function request(params, isGetTonken) { ...@@ -72,7 +73,7 @@ function request(params, isGetTonken) {
} }
}, },
fail: function (err) { fail: function (err) {
console.log('err',err) console.log('err', err)
wx.hideLoading(); wx.hideLoading();
wx.showToast({ wx.showToast({
title: "服务器出了点小差", title: "服务器出了点小差",
...@@ -90,7 +91,7 @@ function uploadImage(url, params, cfg) { ...@@ -90,7 +91,7 @@ function uploadImage(url, params, cfg) {
'Content-Type': 'application/json;charset=UTF-8' 'Content-Type': 'application/json;charset=UTF-8'
} }
wx.showLoading() wx.showLoading()
console.log('params.file',params) console.log('params.file', params)
wx.uploadFile({ wx.uploadFile({
url: config.domain + url, url: config.domain + url,
filePath: params.file, filePath: params.file,
...@@ -122,18 +123,18 @@ function uploadImage(url, params, cfg) { ...@@ -122,18 +123,18 @@ function uploadImage(url, params, cfg) {
cfg.erc(res) cfg.erc(res)
} else if (res.data.msg) { } else if (res.data.msg) {
if (res.data.msg instanceof Array) { if (res.data.msg instanceof Array) {
wx.showToast({title: res.data.msg[0]}) wx.showToast({ title: res.data.msg[0] })
} else { } else {
wx.showToast({title: res.data.msg}) wx.showToast({ title: res.data.msg })
} }
} else { } else {
wx.showToast({title: '请求失败,请重试!'}) wx.showToast({ title: '请求失败,请重试!' })
} }
} }
}, },
fail: err => { fail: err => {
wx.hideLoading() wx.hideLoading()
wx.showToast({title: '图片上传失败,请重试!'}) wx.showToast({ title: '图片上传失败,请重试!' })
if (cfg.erc) { if (cfg.erc) {
cfg.erc(err) cfg.erc(err)
} }
......
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 to comment