Compare commits

..

2 Commits

Author SHA1 Message Date
张慢慢
e4752f75b7 [更新] 2021-05-25 14:00:28 +08:00
张慢慢
4b6e9d9e91 更新 2021-05-24 15:05:14 +08:00
7 changed files with 62 additions and 41 deletions

View File

@@ -8,7 +8,7 @@ const index = (area_name, user_lng, user_lat) => req({url: "home", data: {area_n
const choice = (type, area_name, user_lng, user_lat) => req({url: "home/group", data: {type: type,area_name: area_name, user_lng: user_lng, user_lat:user_lat}})
//权益分类
const classify = (category_id) => req({url: "categories/" + category_id})
const classify = (category_id, area_name, user_lng, user_lat) => req({url: "categories/" + category_id, data: {area_name: area_name, user_lng: user_lng, user_lat:user_lat}})
//周五福利详情
const welfares = (welfare_id) => req({url: "welfare/" + welfare_id})

View File

@@ -2,8 +2,8 @@ import {errInfo} from './err'
import {updToken} from './updateToken'
// 请求方式配置
// https://card.ysd-bs.com
const api = "https://lifetest.ysd-bs.com/api/" //正式地址
// https://card.ysd-bs.com 正式地址
const api = "https://lifetest.ysd-bs.com/api/" //测试地址
const header = {
"Accept" : "application/json"
}

View File

@@ -15,15 +15,26 @@ Page({
content : '', //内容简介
noticeShow : '', //公告开关
infoItems : [], //卡券专区
id : '',
areaname : '',
latitude : '',
userlng : ''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad (options) {
this.indexNav(options.id)
},
this.setData({
id : options.id,
areaname : options.areaname,
latitude : options.latitude,
userlng : options.userlng
})
this.indexNav(options.id,options.areaname,options.latitude,options.userlng)
},
/**
* 生命周期函数--监听页面显示
*/
@@ -34,8 +45,8 @@ Page({
/**
* 卡权益分类
*/
indexNav(id) {
wx.$api.index.classify(id).then(res=>{
indexNav(id, areaname,latitude,userlng) {
wx.$api.index.classify(id, areaname,latitude,userlng).then(res=>{
this.setData({
noticeData : res.data.notice,
infoData : res.data.info,

View File

@@ -146,12 +146,15 @@ Page({
* 处理未登录时的转跳
*/
userNav(e){
let user_lng = this.data.longitude, //经度
user_lat = this.data.latitude, //纬度
area_name = this.data.address.area//城市名称
let id = e.currentTarget.dataset.id
wx.getStorage({
key : 'token',
success:res=>{
wx.navigateTo({
url: '/pages/classify/classify?id=' + id
url: '/pages/classify/classify?id=' + id + '&userlng=' + user_lng + '&latitude=' + user_lat + '&areaname=' + area_name
})
},
fail: (err) => {

View File

@@ -43,41 +43,47 @@ Page({
},
/**
* 登录
* 微信授权登录
*/
userInfo(e){
if(e.detail.errMsg == "getUserInfo:ok"){
this.setData({
isLogin : true,
userInfo : e.detail.rawData,
iv : e.detail.iv,
encryptedData : e.detail.encryptedData
})
// 检查用户登录Code是否过期
wx.checkSession({
success: res=>{
this.userLogin()
},
fail: err=>{
// 登录过期重新获取code
wx.login({
getuserInfo() {
wx.getUserProfile({
desc : "获取你的昵称、头像、地区及性别",
success : e => {
console.log(e)
if(e.errMsg == "getUserProfile:ok"){
this.setData({
isLogin : true,
userInfo : e.rawData,
iv : e.iv,
encryptedData : e.encryptedData
})
// 检查用户登录Code是否过期
wx.checkSession({
success: res=>{
this.setData({
loginCode: res.code
})
// 登录
console.log(res)
this.userLogin()
},
fail: err=>{
// 登录过期重新获取code
wx.login({
success: res=>{
this.setData({
loginCode: res.code
})
// 登录
this.userLogin()
}
})
}
})
}
})
}else{
wx.showToast({
title: '拒绝了登录授权',
icon : 'none'
})
}
},
fail : res => {
//拒绝授权
this.showErrorModal('拒绝了请求');
return;
}
})
},
/**

View File

@@ -2,4 +2,5 @@
<view class="loginImg">
<image src="/static/img/login_img.png" mode="widthFix"></image>
</view>
<button class="loginBtn" size="mini" hover-class="none" open-type="getUserInfo" bindgetuserinfo="userInfo" lang="zh_CN" disabled="{{isLogin}}">用户授权</button>
<button class="loginBtn" size="mini" hover-class="none" bindtap="getuserInfo" disabled="{{isLogin}}">用户授权</button>

View File

@@ -23,7 +23,7 @@
"compileHotReLoad": false,
"useMultiFrameRuntime": true,
"useApiHook": true,
"useApiHostProcess": false,
"useApiHostProcess": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
@@ -41,8 +41,8 @@
},
"compileType": "miniprogram",
"libVersion": "2.12.1",
"appid": "wxb2e3e8091d9feac3",
"projectname": "%E4%BA%BF%E6%97%B6%E4%BB%A3",
"appid": "wx8e424dbdc443381f",
"projectname": "%E4%BA%BF%E6%97%B6%E4%BB%A3%EF%BC%88%E6%B5%8B%E8%AF%95%EF%BC%89",
"debugOptions": {
"hidedInDevtools": []
},