From 0fa2f24268419101d457f3e6ad6cd82cb23c9f23 Mon Sep 17 00:00:00 2001 From: devil Date: Wed, 16 Sep 2020 10:41:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E8=B4=A7=E5=B8=81?= =?UTF-8?q?=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/tags.php | 20 +++ public/static/index/default/css/common.css | 4 +- sourcecode/weixin/app.js | 38 +++++- sourcecode/weixin/app.json | 3 +- .../components/quick-nav/quick-nav.wxss | 5 +- .../plugins/exchangerate/currency/currency.js | 126 ++++++++++++++++++ .../exchangerate/currency/currency.json | 4 + .../exchangerate/currency/currency.wxml | 19 +++ .../exchangerate/currency/currency.wxss | 14 ++ 9 files changed, 224 insertions(+), 9 deletions(-) create mode 100644 sourcecode/weixin/pages/plugins/exchangerate/currency/currency.js create mode 100644 sourcecode/weixin/pages/plugins/exchangerate/currency/currency.json create mode 100644 sourcecode/weixin/pages/plugins/exchangerate/currency/currency.wxml create mode 100644 sourcecode/weixin/pages/plugins/exchangerate/currency/currency.wxss diff --git a/application/tags.php b/application/tags.php index cb3649c9a..bf63f60f3 100755 --- a/application/tags.php +++ b/application/tags.php @@ -107,6 +107,26 @@ return array ( array ( 0 => 'app\\plugins\\exchangerate\\Hook', ), + 'plugins_service_quick_navigation_weixin' => + array ( + 0 => 'app\\plugins\\exchangerate\\Hook', + ), + 'plugins_service_quick_navigation_alipay' => + array ( + 0 => 'app\\plugins\\exchangerate\\Hook', + ), + 'plugins_service_quick_navigation_baidu' => + array ( + 0 => 'app\\plugins\\exchangerate\\Hook', + ), + 'plugins_service_quick_navigation_qq' => + array ( + 0 => 'app\\plugins\\exchangerate\\Hook', + ), + 'plugins_service_quick_navigation_toutiao' => + array ( + 0 => 'app\\plugins\\exchangerate\\Hook', + ), 'plugins_service_currency_price_symbol' => array ( 0 => 'app\\plugins\\exchangerate\\Hook', diff --git a/public/static/index/default/css/common.css b/public/static/index/default/css/common.css index ae1cb605c..180b150e5 100755 --- a/public/static/index/default/css/common.css +++ b/public/static/index/default/css/common.css @@ -969,8 +969,8 @@ legend a.am-fr { background: #d2354c; color: #fff; position: fixed; - left: 20px; - bottom:70px; + left: 10px; + bottom:150px; z-index: 1020; -webkit-box-shadow: 0 0 15px rgba(0, 0, 0, 0.5); -moz-box-shadow: 0 0 15px rgba(0, 0, 0, 0.5); diff --git a/sourcecode/weixin/app.js b/sourcecode/weixin/app.js index 10a2c5e46..eb665073f 100755 --- a/sourcecode/weixin/app.js +++ b/sourcecode/weixin/app.js @@ -1,5 +1,8 @@ App({ data: { + // uuid缓存key + cache_user_uuid_key: "cache_user_uuid_key", + // 配置信息缓存key cache_config_info_key: "cache_config_info_key", @@ -68,7 +71,7 @@ App({ // 请求地址 request_url: "{{request_url}}", request_url: 'http://shopxo.com/', - request_url: 'https://dev.shopxo.net/', + //request_url: 'https://dev.shopxo.net/', // 基础信息 application_title: "{{application_title}}", @@ -174,12 +177,13 @@ App({ // 用户信息 var user = this.get_user_cache_info(); var token = (user == false) ? '' : user.token || ''; + var uuid = this.request_uuid(); return this.data.request_url + "index.php?s=/api/" + c + "/" + a + plugins_params+ "&application=app&application_client_type=weixin" + - "&token=" + - token + + "&token=" + token + "&ajax=ajax" + + "&uuid="+uuid+ params; }, @@ -717,7 +721,7 @@ App({ */ get_config(key, default_value) { var value = null; - let config = wx.getStorageSync(this.data.cache_config_info_key) || null; + var config = wx.getStorageSync(this.data.cache_config_info_key) || null; if(config != null) { // 数据读取 @@ -839,4 +843,30 @@ App({ }); }, + // uuid生成 + uuid() { + var d = new Date().getTime(); + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { + var r = (d + Math.random() * 16) % 16 | 0; + d = Math.floor(d / 16); + return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16); + }); + }, + + // 获取当前uuid + request_uuid() { + var uuid = wx.getStorageSync(this.data.cache_user_uuid_key) || null; + if(uuid == null) { + uuid = this.uuid(); + wx.setStorage({ + key: this.data.cache_user_uuid_key, + data: uuid, + fail: () => { + this.showToast('uuid缓存失败'); + } + }); + } + return uuid; + }, + }); \ No newline at end of file diff --git a/sourcecode/weixin/app.json b/sourcecode/weixin/app.json index 647e92e78..55ecc5159 100755 --- a/sourcecode/weixin/app.json +++ b/sourcecode/weixin/app.json @@ -65,7 +65,8 @@ "pages/plugins/excellentbuyreturntocash/profit-detail/profit-detail", "pages/plugins/weixinliveplayer/index/index", "pages/plugins/weixinliveplayer/search/search", - "pages/plugins/weixinliveplayer/detail/detail" + "pages/plugins/weixinliveplayer/detail/detail", + "pages/plugins/exchangerate/currency/currency" ], "permission": { "scope.userLocation": { diff --git a/sourcecode/weixin/components/quick-nav/quick-nav.wxss b/sourcecode/weixin/components/quick-nav/quick-nav.wxss index 40b7f5ed2..7d91f5f94 100644 --- a/sourcecode/weixin/components/quick-nav/quick-nav.wxss +++ b/sourcecode/weixin/components/quick-nav/quick-nav.wxss @@ -3,13 +3,14 @@ */ .quick-event-submit { position: fixed; - bottom: 50rpx; - left: 50rpx; + bottom: 150rpx; + left: 10rpx; width: 100rpx; height: 100rpx; border-radius: 50%; box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); background-color: #d2364c; + z-index: 2; } .quick-event-submit image { width: 50rpx; diff --git a/sourcecode/weixin/pages/plugins/exchangerate/currency/currency.js b/sourcecode/weixin/pages/plugins/exchangerate/currency/currency.js new file mode 100644 index 000000000..026a0505f --- /dev/null +++ b/sourcecode/weixin/pages/plugins/exchangerate/currency/currency.js @@ -0,0 +1,126 @@ +const app = getApp(); +Page({ + data: { + data_bottom_line_status: false, + data_list_loding_status: 1, + data_list_loding_msg: '', + data_list: [], + data_default: null, + data_base: null, + }, + + onShow() { + // 数据加载 + this.init(); + }, + + // 获取数据 + init() { + this.get_data_list(); + }, + + // 获取数据 + get_data_list() { + var self = this; + wx.showLoading({ title: "加载中..." }); + if (self.data.data_list.length <= 0) + { + self.setData({ + data_list_loding_status: 1 + }); + } + + wx.request({ + url: app.get_request_url("index", "index", "exchangerate"), + method: "POST", + data: {}, + dataType: "json", + success: res => { + wx.hideLoading(); + wx.stopPullDownRefresh(); + if (res.data.code == 0) { + var data = res.data.data; + var status = ((data.data.data || []).length > 0); + this.setData({ + data_base: data.base || null, + data_default: data.data.default || null, + data_list: data.data.data || [], + data_list_loding_msg: '', + data_list_loding_status: status ? 3 : 0, + data_bottom_line_status: status, + }); + } else { + self.setData({ + data_bottom_line_status: false, + data_list_loding_status: 2, + data_list_loding_msg: res.data.msg, + }); + app.showToast(res.data.msg); + } + }, + fail: () => { + wx.hideLoading(); + wx.stopPullDownRefresh(); + self.setData({ + data_bottom_line_status: false, + data_list_loding_status: 2, + data_list_loding_msg: '服务器请求出错', + }); + app.showToast("服务器请求出错"); + } + }); + }, + + // 选择事件 + selected_event(e) { + // 参数处理 + var index = e.currentTarget.dataset.index; + var temp_list = this.data.data_list; + var data = temp_list[index] || null; + if(data == null) + { + app.showToast('数据有误'); + return false; + } + + // id与当前默认一致则不处理 + if (data.id != this.data.data_default.id) + { + var self = this; + wx.showLoading({ title: "处理中..." }); + wx.request({ + url: app.get_request_url("setcurrency", "index", "exchangerate"), + method: "POST", + data: { "currency": data.id }, + dataType: "json", + header: { 'content-type': 'application/x-www-form-urlencoded' }, + success: res => { + wx.hideLoading(); + if (res.data.code == 0) { + app.showToast(res.data.msg, "success"); + self.setData({ data_default: data }); + // 重新初始化配置 + app.init_config(); + + // 返回上一页 + setTimeout(function () { + wx.navigateBack(); + }, 2000); + } else { + app.showToast(res.data.msg); + } + }, + fail: () => { + wx.hideLoading(); + app.showToast("服务器请求出错"); + } + }); + } + }, + + // 下拉刷新 + onPullDownRefresh() { + this.get_data_list(); + }, + +}); diff --git a/sourcecode/weixin/pages/plugins/exchangerate/currency/currency.json b/sourcecode/weixin/pages/plugins/exchangerate/currency/currency.json new file mode 100644 index 000000000..eac1d0379 --- /dev/null +++ b/sourcecode/weixin/pages/plugins/exchangerate/currency/currency.json @@ -0,0 +1,4 @@ +{ + "enablePullDownRefresh": true, + "navigationBarTitleText": "货币切换" +} \ No newline at end of file diff --git a/sourcecode/weixin/pages/plugins/exchangerate/currency/currency.wxml b/sourcecode/weixin/pages/plugins/exchangerate/currency/currency.wxml new file mode 100644 index 000000000..d49982fdb --- /dev/null +++ b/sourcecode/weixin/pages/plugins/exchangerate/currency/currency.wxml @@ -0,0 +1,19 @@ + + + + + + + + {{item.name}} / {{item.symbol}} + + + + + + + + + + + \ No newline at end of file diff --git a/sourcecode/weixin/pages/plugins/exchangerate/currency/currency.wxss b/sourcecode/weixin/pages/plugins/exchangerate/currency/currency.wxss new file mode 100644 index 000000000..14624c1cf --- /dev/null +++ b/sourcecode/weixin/pages/plugins/exchangerate/currency/currency.wxss @@ -0,0 +1,14 @@ +.exchangerate-container .item { + padding: 20rpx 10rpx; + font-size: 36rpx; +} + +.exchangerate-container .item .icon image { + width: 50rpx; + height: 50rpx !important; + margin: 0 10rpx; + vertical-align: middle; +} +.exchangerate-container .item .single-text { + width: calc(100% - 80rpx); +} \ No newline at end of file