提交 0fa2f242 编写于 作者: D devil

小程序货币切换

上级 ca254b06
......@@ -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',
......
......@@ -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);
......
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
......@@ -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": {
......
......@@ -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;
......
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();
},
});
{
"enablePullDownRefresh": true,
"navigationBarTitleText": "货币切换"
}
\ No newline at end of file
<!-- 货币列表 -->
<view wx:if="{{data_list.length > 0}}" class="exchangerate-container">
<block wx:for="{{data_list}}" wx:key="item">
<view class="item oh spacing-mb bg-white" bindtap="selected_event" data-index="{{index}}">
<view wx:if="{{common_site_type != 1}}" class="fl icon">
<image src="/images/default-select{{item.id == data_default.id ? '-active' : ''}}-icon.png" mode="widthFix" />
</view>
<view class="fl single-text {{item.id == data_default.id ? 'cr-main' : 'cr-666'}}">{{item.name}} / {{item.symbol}}</view>
</view>
</block>
</view>
<view wx:if="{{data_list_loding_status != 3}}">
<import src="/pages/common/nodata.wxml" />
<template is="nodata" data="{{status: data_list_loding_status, msg: data_list_loding_msg}}"></template>
</view>
<import src="/pages/common/bottom_line.wxml" />
<template is="bottom_line" data="{{status: data_bottom_line_status}}"></template>
\ No newline at end of file
.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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册