From ad616b543e5ba2e959d62771b3ee1165051fbad1 Mon Sep 17 00:00:00 2001 From: nige Date: Sun, 29 Jan 2023 10:41:06 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5ui=E6=8E=A5=E5=8F=A3=E6=9B=B4?= =?UTF-8?q?=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.js | 279 ++++++++++++++++++++++++++++++--------------------------- 1 file changed, 146 insertions(+), 133 deletions(-) diff --git a/app.js b/app.js index 7acd514..b38ef2f 100644 --- a/app.js +++ b/app.js @@ -2,17 +2,16 @@ import commonApi from "./utils/https/common" App({ onLaunch: function (options) { - if(options.query.authCode){ + if (options.query.authCode) { wx.setStorageSync('authCode', options.query.authCode) - } - else { + } else { wx.removeStorageSync('authCode') } this.updateApp() 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 - commonApi._post("browse/get_uuid",{}).then(res=>{ + commonApi._post("browse/get_uuid", {}).then(res => { // console.log('uuid',res); this.globalData.uuid = res.data.uuid; wx.setStorageSync('uuid', res.data.uuid) @@ -22,10 +21,21 @@ App({ unique_key: "wechatxcx" }).then(res => { let data = JSON.parse(res.data); - data.isTest = data.isTest50?true:false; + data.isTest = data.isTest51 ? true : false; 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({ @@ -50,40 +60,43 @@ App({ this.getShareCategoryId() }, // 更新提示 - updateApp:function(){ + updateApp: function () { const updateManager = wx.getUpdateManager() updateManager.onCheckForUpdate(function (res) { // 请求完新版本信息的回调 if (res.hasUpdate) { wx.showLoading({ - title:'更新下载中...', + title: '更新下载中...', }) } }) updateManager.onUpdateReady(function () { wx.hideLoading(); wx.showModal({ - title:'更新提示', - content:'新版本已经准备好,是否重启应用?', - success:function (res) { + title: '更新提示', + content: '新版本已经准备好,是否重启应用?', + success: function (res) { if (res.confirm) { // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 updateManager.applyUpdate() } } }) - + }) updateManager.onUpdateFailed(function () { // 新的版本下载失败 wx.hideLoading(); - wx.showToast({ title:'下载失败...', icon:"none" }); + wx.showToast({ + title: '下载失败...', + icon: "none" + }); }) }, - getShareCategoryId:function(){ - commonApi._post("share/getShareList",{}).then(res=>{ + getShareCategoryId: function () { + commonApi._post("share/getShareList", {}).then(res => { let CategoryIds = {} - res.data.map(item=>{ + res.data.map(item => { CategoryIds[item.mini] = item.id; }) this.globalData.CategoryIds = CategoryIds; @@ -91,154 +104,154 @@ App({ }) }, //app.js -convertHtmlToText: function(inputText) { - var returnText = "" + inputText; - returnText = returnText.replace(/<\/div>/ig, '\r\n'); - returnText = returnText.replace(/<\/li>/ig, '\r\n'); - returnText = returnText.replace(/
  • /ig, ' * '); - returnText = returnText.replace(/<\/ul>/ig, '\r\n'); - //-- remove BR tags and replace them with line break - returnText = returnText.replace(//g, "\r\n"); + convertHtmlToText: function (inputText) { + var returnText = "" + inputText; + returnText = returnText.replace(/<\/div>/ig, '\r\n'); + returnText = returnText.replace(/<\/li>/ig, '\r\n'); + returnText = returnText.replace(/
  • /ig, ' * '); + returnText = returnText.replace(/<\/ul>/ig, '\r\n'); + //-- remove BR tags and replace them with line break + returnText = returnText.replace(//g, "\r\n"); - //-- remove P and A tags but preserve what's inside of them - returnText = returnText.replace(//g, "\r\n"); - returnText = returnText.replace(/(.*?)<\/a>/g, " $2 ($1)"); + //-- remove P and A tags but preserve what's inside of them + returnText = returnText.replace(//g, "\r\n"); + returnText = returnText.replace(/(.*?)<\/a>/g, " $2 ($1)"); - //-- remove all inside SCRIPT and STYLE tags - returnText = returnText.replace(/[\w\W]{1,}(.*?)[\w\W]{1,}<\/script>/g, ""); - returnText = returnText.replace(/[\w\W]{1,}(.*?)[\w\W]{1,}<\/style>/g, ""); - //-- remove all else - returnText = returnText.replace(/<(?:.|\s)*?>/g, ""); + //-- remove all inside SCRIPT and STYLE tags + returnText = returnText.replace(/[\w\W]{1,}(.*?)[\w\W]{1,}<\/script>/g, ""); + returnText = returnText.replace(/[\w\W]{1,}(.*?)[\w\W]{1,}<\/style>/g, ""); + //-- remove all else + returnText = returnText.replace(/<(?:.|\s)*?>/g, ""); - //-- get rid of more than 2 multiple line breaks: - returnText = returnText.replace(/(?:(?:\r\n|\r|\n)\s*){2,}/g, "\r\n\r\n"); + //-- get rid of more than 2 multiple line breaks: + returnText = returnText.replace(/(?:(?:\r\n|\r|\n)\s*){2,}/g, "\r\n\r\n"); - //-- get rid of more than 2 spaces: - returnText = returnText.replace(/ +(?= )/g, ''); + //-- get rid of more than 2 spaces: + returnText = returnText.replace(/ +(?= )/g, ''); - //-- get rid of html-encoded characters: - returnText = returnText.replace(/ /g, " "); - returnText = returnText.replace(/&/g, "&"); - returnText = returnText.replace(/"/g, '\''); - returnText = returnText.replace(/</g, '<'); - returnText = returnText.replace(/>/g, '>'); - // returnText = returnText.replace(/img/g, 'image'); + //-- get rid of html-encoded characters: + returnText = returnText.replace(/ /g, " "); + returnText = returnText.replace(/&/g, "&"); + returnText = returnText.replace(/"/g, '\''); + returnText = returnText.replace(/</g, '<'); + returnText = returnText.replace(/>/g, '>'); + // returnText = returnText.replace(/img/g, 'image'); - return returnText; -}, + return returnText; + }, //重写分享方法 overShare: function () { //监听路由切换 //间接实现全局设置分享内容 let that = this; wx.onAppRoute(function (res) { - //获取加载的页面 - let pages = getCurrentPages(), - //获取当前页面的对象 - view = pages[pages.length - 1]; - if(view && view.options && view.options.category_id){ - that.globalData.category_id = view.options.category_id; - commonApi._post("share/share",{ - id:view.options.category_id, - url:view.route - }).then(res=>{ - console.log(res) - }) - } - let category_id = that.globalData.CategoryIds[view.route] || null; - if(view.route.indexOf('bike/index')!=-1 && !category_id){ - category_id = that.globalData.CategoryIds[view.route+'?type='+view.options.type] + //获取加载的页面 + let pages = getCurrentPages(), + //获取当前页面的对象 + view = pages[pages.length - 1]; + if (view && view.options && view.options.category_id) { + that.globalData.category_id = view.options.category_id; + commonApi._post("share/share", { + id: view.options.category_id, + url: view.route + }).then(res => { + console.log(res) + }) + } + let category_id = that.globalData.CategoryIds[view.route] || null; + if (view.route.indexOf('bike/index') != -1 && !category_id) { + category_id = that.globalData.CategoryIds[view.route + '?type=' + view.options.type] + } + if (category_id) { + view.options = view.options ? view.options : {}; + let str = []; + for (let i in view.options) { + str.push(i + '=' + view.options[i]) } - if (category_id) { - view.options = view.options?view.options:{}; - let str=[]; - for(let i in view.options){ - str.push(i+'='+view.options[i]) - } - str = str.join("&"); - view.onShareAppMessage = function () { - //你的分享配置 - return { - path: view.route+'?'+str+'&category_id='+category_id - }; - } + str = str.join("&"); + view.onShareAppMessage = function () { + //你的分享配置 + return { + path: view.route + '?' + str + '&category_id=' + category_id + }; } + } }) -}, + }, globalData: { - CategoryIds:{},//分享出去的页面id - category_id:"",//分享进来的参数 - from:"",// 是否是从其他小程序跳转过来的 如果是从其他小程序跳转的话 会记录 - uuid:null,// 设备唯一uuid + CategoryIds: {}, //分享出去的页面id + category_id: "", //分享进来的参数 + from: "", // 是否是从其他小程序跳转过来的 如果是从其他小程序跳转的话 会记录 + uuid: null, // 设备唯一uuid // 苏州市政府的经纬度 - latitude:"31.297401",//纬度 - longitude:"120.585639",//经度 + latitude: "31.297401", //纬度 + longitude: "120.585639", //经度 userInfo: null, - couponInfo:null, - mapKey:"DEUBZ-GG7RR-UZDWR-WXZD3-TARU5-4TB42", - safeBottom:0, - product:null, - postProduct:[], - ticketProduct:[], - index: 0, - createDate: null, - list: null, - productPrice: 0, - ticketPrice: 0, - productState:{ - "WAIT_PAYMENT":"待付款", - "WAIT_CONFIRM":"待确认", - "WAIT_POST":"待发货", - "WAIT_USE":"待出行", - 'WAIT_DELIVERY':'待收货', - 'WAIT_COMMENT':'待评价', - "NEED_REFUND":"退款退货", + couponInfo: null, + mapKey: "DEUBZ-GG7RR-UZDWR-WXZD3-TARU5-4TB42", + safeBottom: 0, + product: null, + postProduct: [], + ticketProduct: [], + index: 0, + createDate: null, + list: null, + productPrice: 0, + ticketPrice: 0, + productState: { + "WAIT_PAYMENT": "待付款", + "WAIT_CONFIRM": "待确认", + "WAIT_POST": "待发货", + "WAIT_USE": "待出行", + 'WAIT_DELIVERY': '待收货', + 'WAIT_COMMENT': '待评价', + "NEED_REFUND": "退款退货", "CLOSED": "已取消", "PAID": "已支付", - "WAIT_REFUND":"待退款", - "REFUND":"已退款", - "COMPLETED":"已完成", - "EXPIRED":"已过期/已失效", - "REFUNDING":"退款中" , - "TICKET_ERROR":"出票失败", - "REFUND_FAIL":"退订失败" + "WAIT_REFUND": "待退款", + "REFUND": "已退款", + "COMPLETED": "已完成", + "EXPIRED": "已过期/已失效", + "REFUNDING": "退款中", + "TICKET_ERROR": "出票失败", + "REFUND_FAIL": "退订失败" }, - orderState:{ - "UNPAID":"待付款", + orderState: { + "UNPAID": "待付款", // "WAIT_PAYMENT":"待付款", // "WAIT_CONFIRM":"待确认", // "WAIT_POST":"待发货", // "WAIT_USE":"待出行", // 'WAIT_DELIVERY':'待收货', - 'WAIT_COMMENT':'待评价', + 'WAIT_COMMENT': '待评价', // "NEED_REFUND":"退款退货", "CLOSED": "已取消", "PAID": "已支付", - "WAIT_REFUND":"待退款", - "REFUND":"已退款", - "COMPLETED":"已完成", + "WAIT_REFUND": "待退款", + "REFUND": "已退款", + "COMPLETED": "已完成", // "EXPIRED":"已过期/已失效", - "REFUNDING":"退款中" , - 'REFUND_REFUSE':'退款拒绝', - 'REFUND_ERROR':'退款异常', - 'OFFLINE_REFUND':'线下退款完成', - 'OFFLINE_WAIT':'线下退款处理中' + "REFUNDING": "退款中", + 'REFUND_REFUSE': '退款拒绝', + 'REFUND_ERROR': '退款异常', + 'OFFLINE_REFUND': '线下退款完成', + 'OFFLINE_WAIT': '线下退款处理中' }, - codeState:['未使用','已使用','已失效','已取消'], - weburl:"", - pay_methods:{ - NONE:"无需支付", - WEIXIN:"微信支付", - JIANSHEYINHANG:"建行支付", - ZHIFUBAO:"支付宝支付" + codeState: ['未使用', '已使用', '已失效', '已取消'], + weburl: "", + pay_methods: { + NONE: "无需支付", + WEIXIN: "微信支付", + JIANSHEYINHANG: "建行支付", + ZHIFUBAO: "支付宝支付" }, - kjId:null, - gp_id:null, - team_id:null, - retailId:"", - configJson:null, - prizeId:null, - loginPageEvent:{ + kjId: null, + gp_id: null, + team_id: null, + retailId: "", + configJson: null, + prizeId: null, + loginPageEvent: { "pages/list/message/index": 'message_login_' } }