Files
sphc/pages/my/my.js

344 lines
8.2 KiB
JavaScript
Raw Normal View History

2024-05-06 15:34:15 +08:00
// pages/my/my.js
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
bgImg: app.globalData.bgImg,
statusBarHeight: app.globalData.statusBarHeight,
orderType: [
{ icon: '/icon/order-1.png', name: '待支付', state: 1 },
{ icon: '/icon/order-2.png', name: '待发货', state: 2 },
{ icon: '/icon/order-3.png', name: '待收货', state: 3 },
{ icon: '/icon/order-5.png', name: '退款售后', state: 6 },
{ icon: '/icon/order-4.png', name: '已完成', state: 4 },
],
orderTypeB: [
{ icon: '/icon/my-1.png', name: '我的主页' },
{ icon: '/icon/my-2.png', name: '我的账单' },
{ icon: '/icon/my-3.png', name: '我的地址' },
{ icon: '/icon/my-4.png', name: '问题反馈' },
{ icon: '/icon/my-5.png', name: '关于我们' },
{ icon: '/icon/my-6.png', name: '联系客服' },
{ icon: '/icon/my-7.png', name: '会员介绍' },
],
login: false,
rules: false,
rulesCont: '',
},
onLoad: function (options) {
//上级id
if (options.pId) {
wx.setStorage({
data: options.pId,
key: 'pId',
})
}
},
onShow: function () {
//判断登录
wx.getStorage({
key: 'user',
success: user => {
//个人信息
wx.showLoading({
title: '加载中..',
})
wx.request({
url: app.globalData.ip + '/wisdommining/api/user/getTwoGoodsType',
method: 'GET',
header: {
"content-type": "application/x-www-form-urlencoded",
},
data: {
userId: user.data.id
},
success: res => {
wx.hideLoading()
console.log(res)
if (res.data.code == 1) {
this.setData({
user: res.data.value,
login: true
})
//获取ID
app.globalData.userId = res.data.value.id;
wx.setStorage({
key: 'user',
data: res.data.value,
})
//积分 团队
wx.request({
url: app.globalData.ip + '/wisdommining/api/user/getIntetralEarnings',
method: 'GET',
header: {
"content-type": "application/x-www-form-urlencoded",
},
data: {
userId: user.data.id
},
success: res => {
wx.hideLoading()
console.log(res)
if (res.data.code == 1) {
this.setData({
integralData: res.data.value,
rulesCont: res.data.value.wisdIntegrlRoles.rolesContent,
})
} else {
wx.showModal({
title: '提示!',
content: res.data.message,
showCancel: false,
})
}
}
})
} else {
wx.showModal({
title: '提示!',
content: res.data.message,
showCancel: false,
})
}
}
})
},
fail: e => {
this.setData({
login: false
})
}
})
},
//积分规则
rules() {
this.setData({
rules: true,
})
},
//积分规则删除
rulesDel() {
this.setData({
rules: false,
})
},
//我的团队
ourteam() {
if(!this.data.login){
app.login_no()
return
}
wx.navigateTo({
url: '/pages/my/ourteam/ourteam',
})
},
//登录
goLogin() {
wx.navigateTo({
url: '/pages/login/login',
})
},
type(e) {
let name = e.currentTarget.dataset.name;
if(!this.data.login&&name!='联系客服'){
app.login_no()
return
}
if (name == '我的主页') {
if (this.data.user.userIscompany == 0) {
wx.navigateTo({
url: '/pages/bindCompany/bindCompany',
})
} else {
wx.navigateTo({
url: '/pages/my/my_data/my_data',
})
}
}
if (name == '我的地址') {
wx.navigateTo({
url: '/pages/my/my_address/my_address',
})
}
if (name == '问题反馈') {
wx.navigateTo({
url: '/pages/my/my_feedback_list/my_feedback_list',
})
}
if (name == '关于我们') {
wx.navigateTo({
url: '/pages/my/my_introduction/my_introduction',
})
}
if (name == '我的账单') {
wx.navigateTo({
url: '/pages/my/my_bill/my_bill',
})
}
if (name == '会员介绍') {
wx.navigateTo({
url: '/pages/my/my_vipjs/my_introduction',
})
}
},
vipjs(){
wx.navigateTo({
url: '/pages/my/my_vipjs/my_introduction',
})
},
//订单
order: function (e) {
if(!this.data.login){
app.login_no()
return
}
wx.navigateTo({
url: '/pages/my/my_order/my_order?state=' + e.currentTarget.dataset.state,
})
},
//套餐券
coupon() {
if(!this.data.login){
app.login_no()
return
}
wx.navigateTo({
url: '/pages/my/coupon/coupon',
})
},
//钱包
wallet() {
if(!this.data.login){
app.login_no()
return
}
wx.navigateTo({
url: '/pages/my/my_wallet/my_wallet',
})
},
//商铺
shops() {
wx.navigateTo({
url: '/pages/my/shops/shops',
})
},
map() {
var that = this;
wx.getSetting({
success(res) {
console.log('get-setting', res.authSetting);
// 只返回用户请求过的授权
let auth = res.authSetting;
if (auth['scope.userLocation']) {
// 已授权,申请定位地址
that.toAddress();
} else if (auth['scope.userLocation'] === undefined) {
// 用户没有请求过的授权,不需要我们主动弹窗,微信会提供弹窗
that.toAddress();
} else if (!auth['scope.userLocation']) {
// 没有授权过,需要用户重新授权
// 这个弹窗是为了实现点击不然openSetting会失败
wx.showModal({
title: '是否授权位置信息?',
content: '需要获取您的位置信息,请确认授权',
success: res => {
if (res.confirm) {
wx.openSetting({
success(res) {
console.log('位置信息', res.authSetting);
console.log('open-setting-suc', res.authSetting);
let setting = res.authSetting;
if (!setting['scope.userLocation']) {
wx.showToast({
title: '位置信息授权失败',
icon: 'none',
});
} else {
// 地址授权成功,申请定位地址
that.toAddress();
}
},
fail(err) {
// 需要点击有时候没有点击是无法触发openSetting
console.log('open-setting-fail', err);
}
});
}
}
});
}
}
});
},
// 调用地址
toAddress: function (options) {
wx.navigateTo({
url: '/pages/index/index_address/index_address',
})
},
//客服电话
customerPhone(){
wx.makePhoneCall({
phoneNumber: app.globalData.customerPhone,
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
app.share();
return {
path: '/pages/index/index?pId=' + app.globalData.userId,
title: '三品慧采小程序等你来~'
}
},
})