Browse Source

首页ui接口更换

master
nige 3 years ago
parent
commit
ad616b543e
  1. 177
      app.js

177
app.js

@ -2,17 +2,16 @@
import commonApi from "./utils/https/common" import commonApi from "./utils/https/common"
App({ App({
onLaunch: function (options) { onLaunch: function (options) {
if(options.query.authCode){ if (options.query.authCode) {
wx.setStorageSync('authCode', options.query.authCode) wx.setStorageSync('authCode', options.query.authCode)
} } else {
else {
wx.removeStorageSync('authCode') wx.removeStorageSync('authCode')
} }
this.updateApp() this.updateApp()
let rect = wx.getSystemInfoSync(); let rect = wx.getSystemInfoSync();
this.globalData.safeBottom = rect.safeArea?(rect.safeArea.bottom - rect.safeArea.height):0 this.globalData.safeBottom = rect.safeArea ? (rect.safeArea.bottom - rect.safeArea.height) : 0
// 获取uuid // 获取uuid
commonApi._post("browse/get_uuid",{}).then(res=>{ commonApi._post("browse/get_uuid", {}).then(res => {
// console.log('uuid',res); // console.log('uuid',res);
this.globalData.uuid = res.data.uuid; this.globalData.uuid = res.data.uuid;
wx.setStorageSync('uuid', res.data.uuid) wx.setStorageSync('uuid', res.data.uuid)
@ -22,11 +21,22 @@ App({
unique_key: "wechatxcx" unique_key: "wechatxcx"
}).then(res => { }).then(res => {
let data = JSON.parse(res.data); let data = JSON.parse(res.data);
data.isTest = data.isTest50?true:false; data.isTest = data.isTest51 ? true : false;
this.globalData.configJson = data this.globalData.configJson = data
}).then(() => {
// 获取ui配置文件
commonApi._post("adv/get_home_ui", {}).then(res => {
let obj = {}
res.data.content.forEach(item => {
obj[item.id] = item.image
});
this.globalData.configJson.indexSeason = obj
})
}) })
// 获取用户信息 // 获取用户信息
// wx.getSetting({ // wx.getSetting({
// success: res => { // success: res => {
@ -50,22 +60,22 @@ App({
this.getShareCategoryId() this.getShareCategoryId()
}, },
// 更新提示 // 更新提示
updateApp:function(){ updateApp: function () {
const updateManager = wx.getUpdateManager() const updateManager = wx.getUpdateManager()
updateManager.onCheckForUpdate(function (res) { updateManager.onCheckForUpdate(function (res) {
// 请求完新版本信息的回调 // 请求完新版本信息的回调
if (res.hasUpdate) { if (res.hasUpdate) {
wx.showLoading({ wx.showLoading({
title:'更新下载中...', title: '更新下载中...',
}) })
} }
}) })
updateManager.onUpdateReady(function () { updateManager.onUpdateReady(function () {
wx.hideLoading(); wx.hideLoading();
wx.showModal({ wx.showModal({
title:'更新提示', title: '更新提示',
content:'新版本已经准备好,是否重启应用?', content: '新版本已经准备好,是否重启应用?',
success:function (res) { success: function (res) {
if (res.confirm) { if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate() updateManager.applyUpdate()
@ -77,13 +87,16 @@ App({
updateManager.onUpdateFailed(function () { updateManager.onUpdateFailed(function () {
// 新的版本下载失败 // 新的版本下载失败
wx.hideLoading(); wx.hideLoading();
wx.showToast({ title:'下载失败...', icon:"none" }); wx.showToast({
title: '下载失败...',
icon: "none"
});
}) })
}, },
getShareCategoryId:function(){ getShareCategoryId: function () {
commonApi._post("share/getShareList",{}).then(res=>{ commonApi._post("share/getShareList", {}).then(res => {
let CategoryIds = {} let CategoryIds = {}
res.data.map(item=>{ res.data.map(item => {
CategoryIds[item.mini] = item.id; CategoryIds[item.mini] = item.id;
}) })
this.globalData.CategoryIds = CategoryIds; this.globalData.CategoryIds = CategoryIds;
@ -91,7 +104,7 @@ App({
}) })
}, },
//app.js //app.js
convertHtmlToText: function(inputText) { convertHtmlToText: function (inputText) {
var returnText = "" + inputText; var returnText = "" + inputText;
returnText = returnText.replace(/<\/div>/ig, '\r\n'); returnText = returnText.replace(/<\/div>/ig, '\r\n');
returnText = returnText.replace(/<\/li>/ig, '\r\n'); returnText = returnText.replace(/<\/li>/ig, '\r\n');
@ -125,7 +138,7 @@ convertHtmlToText: function(inputText) {
// returnText = returnText.replace(/img/g, 'image'); // returnText = returnText.replace(/img/g, 'image');
return returnText; return returnText;
}, },
//重写分享方法 //重写分享方法
overShare: function () { overShare: function () {
//监听路由切换 //监听路由切换
@ -136,109 +149,109 @@ convertHtmlToText: function(inputText) {
let pages = getCurrentPages(), let pages = getCurrentPages(),
//获取当前页面的对象 //获取当前页面的对象
view = pages[pages.length - 1]; view = pages[pages.length - 1];
if(view && view.options && view.options.category_id){ if (view && view.options && view.options.category_id) {
that.globalData.category_id = view.options.category_id; that.globalData.category_id = view.options.category_id;
commonApi._post("share/share",{ commonApi._post("share/share", {
id:view.options.category_id, id: view.options.category_id,
url:view.route url: view.route
}).then(res=>{ }).then(res => {
console.log(res) console.log(res)
}) })
} }
let category_id = that.globalData.CategoryIds[view.route] || null; let category_id = that.globalData.CategoryIds[view.route] || null;
if(view.route.indexOf('bike/index')!=-1 && !category_id){ if (view.route.indexOf('bike/index') != -1 && !category_id) {
category_id = that.globalData.CategoryIds[view.route+'?type='+view.options.type] category_id = that.globalData.CategoryIds[view.route + '?type=' + view.options.type]
} }
if (category_id) { if (category_id) {
view.options = view.options?view.options:{}; view.options = view.options ? view.options : {};
let str=[]; let str = [];
for(let i in view.options){ for (let i in view.options) {
str.push(i+'='+view.options[i]) str.push(i + '=' + view.options[i])
} }
str = str.join("&"); str = str.join("&");
view.onShareAppMessage = function () { view.onShareAppMessage = function () {
//你的分享配置 //你的分享配置
return { return {
path: view.route+'?'+str+'&category_id='+category_id path: view.route + '?' + str + '&category_id=' + category_id
}; };
} }
} }
}) })
}, },
globalData: { globalData: {
CategoryIds:{},//分享出去的页面id CategoryIds: {}, //分享出去的页面id
category_id:"",//分享进来的参数 category_id: "", //分享进来的参数
from:"",// 是否是从其他小程序跳转过来的 如果是从其他小程序跳转的话 会记录 from: "", // 是否是从其他小程序跳转过来的 如果是从其他小程序跳转的话 会记录
uuid:null,// 设备唯一uuid uuid: null, // 设备唯一uuid
// 苏州市政府的经纬度 // 苏州市政府的经纬度
latitude:"31.297401",//纬度 latitude: "31.297401", //纬度
longitude:"120.585639",//经度 longitude: "120.585639", //经度
userInfo: null, userInfo: null,
couponInfo:null, couponInfo: null,
mapKey:"DEUBZ-GG7RR-UZDWR-WXZD3-TARU5-4TB42", mapKey: "DEUBZ-GG7RR-UZDWR-WXZD3-TARU5-4TB42",
safeBottom:0, safeBottom: 0,
product:null, product: null,
postProduct:[], postProduct: [],
ticketProduct:[], ticketProduct: [],
index: 0, index: 0,
createDate: null, createDate: null,
list: null, list: null,
productPrice: 0, productPrice: 0,
ticketPrice: 0, ticketPrice: 0,
productState:{ productState: {
"WAIT_PAYMENT":"待付款", "WAIT_PAYMENT": "待付款",
"WAIT_CONFIRM":"待确认", "WAIT_CONFIRM": "待确认",
"WAIT_POST":"待发货", "WAIT_POST": "待发货",
"WAIT_USE":"待出行", "WAIT_USE": "待出行",
'WAIT_DELIVERY':'待收货', 'WAIT_DELIVERY': '待收货',
'WAIT_COMMENT':'待评价', 'WAIT_COMMENT': '待评价',
"NEED_REFUND":"退款退货", "NEED_REFUND": "退款退货",
"CLOSED": "已取消", "CLOSED": "已取消",
"PAID": "已支付", "PAID": "已支付",
"WAIT_REFUND":"待退款", "WAIT_REFUND": "待退款",
"REFUND":"已退款", "REFUND": "已退款",
"COMPLETED":"已完成", "COMPLETED": "已完成",
"EXPIRED":"已过期/已失效", "EXPIRED": "已过期/已失效",
"REFUNDING":"退款中" , "REFUNDING": "退款中",
"TICKET_ERROR":"出票失败", "TICKET_ERROR": "出票失败",
"REFUND_FAIL":"退订失败" "REFUND_FAIL": "退订失败"
}, },
orderState:{ orderState: {
"UNPAID":"待付款", "UNPAID": "待付款",
// "WAIT_PAYMENT":"待付款", // "WAIT_PAYMENT":"待付款",
// "WAIT_CONFIRM":"待确认", // "WAIT_CONFIRM":"待确认",
// "WAIT_POST":"待发货", // "WAIT_POST":"待发货",
// "WAIT_USE":"待出行", // "WAIT_USE":"待出行",
// 'WAIT_DELIVERY':'待收货', // 'WAIT_DELIVERY':'待收货',
'WAIT_COMMENT':'待评价', 'WAIT_COMMENT': '待评价',
// "NEED_REFUND":"退款退货", // "NEED_REFUND":"退款退货",
"CLOSED": "已取消", "CLOSED": "已取消",
"PAID": "已支付", "PAID": "已支付",
"WAIT_REFUND":"待退款", "WAIT_REFUND": "待退款",
"REFUND":"已退款", "REFUND": "已退款",
"COMPLETED":"已完成", "COMPLETED": "已完成",
// "EXPIRED":"已过期/已失效", // "EXPIRED":"已过期/已失效",
"REFUNDING":"退款中" , "REFUNDING": "退款中",
'REFUND_REFUSE':'退款拒绝', 'REFUND_REFUSE': '退款拒绝',
'REFUND_ERROR':'退款异常', 'REFUND_ERROR': '退款异常',
'OFFLINE_REFUND':'线下退款完成', 'OFFLINE_REFUND': '线下退款完成',
'OFFLINE_WAIT':'线下退款处理中' 'OFFLINE_WAIT': '线下退款处理中'
}, },
codeState:['未使用','已使用','已失效','已取消'], codeState: ['未使用', '已使用', '已失效', '已取消'],
weburl:"", weburl: "",
pay_methods:{ pay_methods: {
NONE:"无需支付", NONE: "无需支付",
WEIXIN:"微信支付", WEIXIN: "微信支付",
JIANSHEYINHANG:"建行支付", JIANSHEYINHANG: "建行支付",
ZHIFUBAO:"支付宝支付" ZHIFUBAO: "支付宝支付"
}, },
kjId:null, kjId: null,
gp_id:null, gp_id: null,
team_id:null, team_id: null,
retailId:"", retailId: "",
configJson:null, configJson: null,
prizeId:null, prizeId: null,
loginPageEvent:{ loginPageEvent: {
"pages/list/message/index": 'message_login_' "pages/list/message/index": 'message_login_'
} }
} }

Loading…
Cancel
Save