This commit is contained in:
parent
834053b672
commit
9630dd8403
|
@ -0,0 +1,201 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
|
@ -0,0 +1,143 @@
|
|||
var util = require('lib/util.js');
|
||||
var timeQueue = require('eaterplanet_ecommerce/utils/timeQueue');
|
||||
var mta = require('lib/mta_analysis.js');
|
||||
require('eaterplanet_ecommerce/utils//mixins.js');
|
||||
require('/lib/SPage.js')
|
||||
|
||||
App({
|
||||
onLaunch: async function (options) {
|
||||
let scene = options.scene || '';
|
||||
this.globalData.scene = scene;
|
||||
console.log('scene:' + scene);
|
||||
var userInfo = wx.getStorageSync("userInfo");
|
||||
this.globalData.userInfo = userInfo;
|
||||
wx.setStorageSync("isparse_formdata", 0);
|
||||
var currentCommunity = wx.getStorageSync("community");
|
||||
this.globalData.hasDefaultCommunity = !!currentCommunity;
|
||||
this.globalData.community = currentCommunity;
|
||||
this.globalData.systemInfo = wx.getSystemInfoSync();
|
||||
var model = this.globalData.systemInfo.model;
|
||||
this.globalData.isIpx = model.indexOf("iPhone X") > -1 || model.indexOf("unknown<iPhone") > -1;
|
||||
this.globalData.timer = new timeQueue.default();
|
||||
mta.App.init({
|
||||
"appID": "",
|
||||
"eventID": "",
|
||||
"autoReport": true,
|
||||
"statParam": true,
|
||||
"ignoreParams": ['test_adt'],
|
||||
"lauchOpts": true,
|
||||
"statPullDownFresh": true,
|
||||
"statShareApp": true,
|
||||
"statReachBottom": true
|
||||
});
|
||||
},
|
||||
$mixinP:{
|
||||
onLoad(options){
|
||||
console.log("options", options)
|
||||
}
|
||||
},
|
||||
onShow: function () {
|
||||
if(this.globalData.scene!=1154) this.getUpdate();
|
||||
},
|
||||
onHide: function () {
|
||||
},
|
||||
|
||||
util: util,
|
||||
userInfo: {
|
||||
sessionid: null,
|
||||
},
|
||||
globalData: {
|
||||
systemInfo: {},
|
||||
isIpx: false,
|
||||
userInfo: {},
|
||||
canGetGPS: true,
|
||||
city: {},
|
||||
community: {},
|
||||
location: {},
|
||||
hasDefaultCommunity: true,
|
||||
historyCommunity: [],
|
||||
changedCommunity: false,
|
||||
disUserInfo: {},
|
||||
changeCity: "",
|
||||
timer: 0,
|
||||
formIds: [],
|
||||
community_id: '',
|
||||
placeholdeImg: '',
|
||||
cartNum: 0,
|
||||
cartNumStamp: 0,
|
||||
common_header_backgroundimage: '',
|
||||
appLoadStatus: 1, // 1 正常 0 未登录 2 未选择社区
|
||||
goodsListCarCount: [],
|
||||
typeCateId: 0,
|
||||
navBackUrl: '',
|
||||
isblack: 0,
|
||||
statusBarHeight: wx.getSystemInfoSync()['statusBarHeight'],
|
||||
skin: {
|
||||
color: '#ff5344',
|
||||
subColor: '#ed7b3a',
|
||||
lighter: '#fff9f4'
|
||||
},
|
||||
goods_sale_unit: '件',
|
||||
scene: '',
|
||||
indexCateId: '',
|
||||
},
|
||||
getUpdate: function(){
|
||||
if (wx.canIUse("getUpdateManager")) {
|
||||
const updateManager = wx.getUpdateManager();
|
||||
updateManager.onCheckForUpdate(function (res) {
|
||||
res.hasUpdate && (updateManager.onUpdateReady(function () {
|
||||
wx.showModal({
|
||||
title: "更新提示",
|
||||
content: "新版本已经准备好,是否马上重启小程序?",
|
||||
success: function (t) {
|
||||
t.confirm && updateManager.applyUpdate();
|
||||
}
|
||||
});
|
||||
}), updateManager.onUpdateFailed(function () {
|
||||
wx.showModal({
|
||||
title: "已经有新版本了哟~",
|
||||
content: "新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~"
|
||||
});
|
||||
}));
|
||||
});
|
||||
} else wx.showModal({
|
||||
title: "提示",
|
||||
content: "当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。"
|
||||
});
|
||||
},
|
||||
getConfig: function() {
|
||||
var token = wx.getStorageSync('token');
|
||||
return new Promise((resolve, reject)=>{
|
||||
util.request({
|
||||
url: 'entry/wxapp/user',
|
||||
data: {
|
||||
controller: 'index.get_firstload_msg',
|
||||
token,
|
||||
m: 'eaterplanet_ecommerce'
|
||||
},
|
||||
method: 'post',
|
||||
dataType: 'json',
|
||||
success: function(res) {
|
||||
if(res.data.code==0) {
|
||||
let { new_head_id, default_head_info, isparse_formdata } = res.data;
|
||||
if(!token) isparse_formdata = 0;
|
||||
wx.setStorageSync('isparse_formdata', isparse_formdata);
|
||||
|
||||
if(new_head_id>0&&Object.keys(default_head_info).length) {
|
||||
wx.setStorageSync('community', default_head_info);
|
||||
}
|
||||
resolve(res)
|
||||
} else {
|
||||
reject()
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
setShareConfig: function(){
|
||||
wx.showShareMenu({
|
||||
menus: ['shareAppMessage', 'shareTimeline']
|
||||
})
|
||||
},
|
||||
siteInfo: require('siteinfo.js')
|
||||
});
|
|
@ -0,0 +1,231 @@
|
|||
{
|
||||
"pages": [
|
||||
"eaterplanet_ecommerce/pages/index/advert",
|
||||
"eaterplanet_ecommerce/pages/index/index",
|
||||
"eaterplanet_ecommerce/pages/goods/goodsDetail",
|
||||
"eaterplanet_ecommerce/pages/order/shopCart",
|
||||
"eaterplanet_ecommerce/pages/user/me",
|
||||
"eaterplanet_ecommerce/pages/position/community",
|
||||
"eaterplanet_ecommerce/pages/position/search",
|
||||
"eaterplanet_ecommerce/pages/order/index",
|
||||
"eaterplanet_ecommerce/pages/order/order",
|
||||
"eaterplanet_ecommerce/pages/order/refunddetail",
|
||||
"eaterplanet_ecommerce/pages/user/protocol",
|
||||
"eaterplanet_ecommerce/pages/user/articleProtocol",
|
||||
"eaterplanet_ecommerce/pages/order/refund",
|
||||
"eaterplanet_ecommerce/pages/order/evaluate",
|
||||
"eaterplanet_ecommerce/pages/position/cities",
|
||||
"eaterplanet_ecommerce/pages/order/placeOrder",
|
||||
"eaterplanet_ecommerce/pages/goods/buyRecords",
|
||||
"eaterplanet_ecommerce/pages/goods/comment",
|
||||
"eaterplanet_ecommerce/pages/supply/recruit",
|
||||
"eaterplanet_ecommerce/pages/supply/apply",
|
||||
"eaterplanet_ecommerce/pages/web-view",
|
||||
"eaterplanet_ecommerce/pages/order/goods_express",
|
||||
"eaterplanet_ecommerce/pages/order/shareOrderInfo",
|
||||
"eaterplanet_ecommerce/pages/user/coupon",
|
||||
"eaterplanet_ecommerce/pages/index/share",
|
||||
"eaterplanet_ecommerce/pages/type/index",
|
||||
"eaterplanet_ecommerce/pages/user/rechargeDetails",
|
||||
"eaterplanet_ecommerce/pages/user/charge",
|
||||
"eaterplanet_ecommerce/pages/type/search",
|
||||
"eaterplanet_ecommerce/pages/type/result",
|
||||
"eaterplanet_ecommerce/pages/goods/industrial",
|
||||
"eaterplanet_ecommerce/pages/supply/index",
|
||||
"eaterplanet_ecommerce/pages/supply/home",
|
||||
"eaterplanet_ecommerce/pages/refund/refundList",
|
||||
"eaterplanet_ecommerce/pages/type/details",
|
||||
"eaterplanet_ecommerce/pages/user/rule"
|
||||
],
|
||||
"window": {
|
||||
"navigationStyle": "custom",
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "",
|
||||
"navigationBarBackgroundColor": "#007FAF",
|
||||
"backgroundColor": "#fff"
|
||||
},
|
||||
"tabBar": {
|
||||
"list": [
|
||||
{
|
||||
"pagePath": "eaterplanet_ecommerce/pages/index/index",
|
||||
"text": "首页"
|
||||
},
|
||||
{
|
||||
"pagePath": "eaterplanet_ecommerce/pages/type/index",
|
||||
"text": "分类"
|
||||
},
|
||||
{
|
||||
"pagePath": "eaterplanet_ecommerce/pages/order/shopCart",
|
||||
"text": "购物车"
|
||||
},
|
||||
{
|
||||
"pagePath": "eaterplanet_ecommerce/pages/user/me",
|
||||
"text": "我的"
|
||||
}
|
||||
],
|
||||
"color": "#fff",
|
||||
"selectedColor": "#fff",
|
||||
"backgroundColor": "#fff",
|
||||
"borderStyle": "white"
|
||||
},
|
||||
"networkTimeout": {
|
||||
"request": 20000
|
||||
},
|
||||
"permission": {
|
||||
"scope.userLocation": {
|
||||
"desc": "为了更好的服务您,请授权允许"
|
||||
}
|
||||
},
|
||||
"subPackages": [
|
||||
{
|
||||
"name": "distributionCenter",
|
||||
"root": "eaterplanet_ecommerce/distributionCenter",
|
||||
"pages": [
|
||||
"pages/share",
|
||||
"pages/member",
|
||||
"pages/memberInfo",
|
||||
"pages/details",
|
||||
"pages/me",
|
||||
"pages/recruit",
|
||||
"pages/apply",
|
||||
"pages/excharge",
|
||||
"pages/exchargeRecord",
|
||||
"pages/goodsDetails",
|
||||
"pages/fans"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "moduleA",
|
||||
"root": "eaterplanet_ecommerce/moduleA",
|
||||
"pages": [
|
||||
"special/index",
|
||||
"special/list",
|
||||
"pin/goodsDetail",
|
||||
"pin/share",
|
||||
"pin/me",
|
||||
"pin/rule",
|
||||
"pin/index",
|
||||
"pin/income",
|
||||
"pin/excharge",
|
||||
"pin/exchargeRecord",
|
||||
"vip/upgrade",
|
||||
"vip/notice",
|
||||
"score/signin",
|
||||
"score/scoreDetails",
|
||||
"menu/index",
|
||||
"menu/fav",
|
||||
"menu/subcate",
|
||||
"menu/list",
|
||||
"menu/details",
|
||||
"seckill/list",
|
||||
"solitaire/pub",
|
||||
"solitaire/index",
|
||||
"solitaire/details",
|
||||
"video/index",
|
||||
"video/detail",
|
||||
"solitaire/me",
|
||||
"solitaire/groupIndex",
|
||||
"solitaire/addGood",
|
||||
"solitaire/groupDetails",
|
||||
"solitaire/order",
|
||||
"solitaire/share",
|
||||
"solitaire/shareDetails",
|
||||
"groupCenter/index",
|
||||
"groupCenter/recruit",
|
||||
"groupCenter/apply",
|
||||
"groupCenter/communityMembers",
|
||||
"groupCenter/distributionList",
|
||||
"groupCenter/distributionInstruct",
|
||||
"groupCenter/settlementList",
|
||||
"groupCenter/settlementDetail",
|
||||
"groupCenter/editInfo",
|
||||
"groupCenter/groupList",
|
||||
"groupCenter/groupDetail",
|
||||
"groupCenter/buyHistory",
|
||||
"groupCenter/pendingDeliveryOrders",
|
||||
"groupCenter/wallet",
|
||||
"groupCenter/cashList",
|
||||
"groupCenter/detailsList",
|
||||
"groupCenter/list",
|
||||
"groupCenter/listDetails",
|
||||
"groupCenter/memberList",
|
||||
"groupCenter/setting",
|
||||
"groupCenter/closure",
|
||||
"groupCenter/addHexiao",
|
||||
"groupCenter/bind_member_hexiao",
|
||||
"groupCenter/goodsManage",
|
||||
"groupCenter/gruopInfo",
|
||||
"groupCenter/headlist",
|
||||
"groupCenter/recommend",
|
||||
"groupCenter/ranking",
|
||||
"coupon/getCoupon",
|
||||
"editUser/index"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "moduleB",
|
||||
"root": "eaterplanet_ecommerce/moduleB",
|
||||
"pages": [
|
||||
"index/index",
|
||||
"writeoff/index",
|
||||
"index/auth",
|
||||
"live/index",
|
||||
"writeoff/member",
|
||||
"rider/index",
|
||||
"rider/order",
|
||||
"rider/grab",
|
||||
"supply/index",
|
||||
"live/replay",
|
||||
"supply/goodsManage",
|
||||
"supply/orderManage",
|
||||
"generalmall/index",
|
||||
"supply/moneyManage",
|
||||
"supply/excharge",
|
||||
"supply/exchargeRecord",
|
||||
"supply/orderDetails",
|
||||
"supply/editSku",
|
||||
"rider/census",
|
||||
"rider/me",
|
||||
"rider/excharge",
|
||||
"rider/exchargeRecord",
|
||||
"rider/accountRecord",
|
||||
"writeoff/details",
|
||||
"supply/changePrice",
|
||||
"order/share",
|
||||
"presale/index",
|
||||
"invite/index",
|
||||
"invite/reward",
|
||||
"invite/scoreList",
|
||||
"invite/record",
|
||||
"invite/share",
|
||||
"virtualcard/index",
|
||||
"virtualcard/exchange",
|
||||
"manage/index",
|
||||
"offlineCode/index"
|
||||
]
|
||||
}
|
||||
],
|
||||
"preloadRule": {
|
||||
"eaterplanet_ecommerce/pages/user/me": {
|
||||
"network": "all",
|
||||
"packages": [
|
||||
"moduleA",
|
||||
"distributionCenter",
|
||||
"moduleB"
|
||||
]
|
||||
}
|
||||
},
|
||||
"sitemapLocation": "sitemap.json",
|
||||
"usingComponents": {
|
||||
"i-vip-modal": "/eaterplanet_ecommerce/components/vipModal/index"
|
||||
},
|
||||
"requiredBackgroundModes": [
|
||||
"audio"
|
||||
],
|
||||
"usingShopPlugin": true,
|
||||
"requiredPrivateInfos": [
|
||||
"chooseAddress",
|
||||
"chooseLocation",
|
||||
"getLocation"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,404 @@
|
|||
@import "/icon.wxss";
|
||||
@import "/common.wxss";
|
||||
page {
|
||||
background-color: #f6f6f6;
|
||||
font-size: 28rpx;
|
||||
font-weight: 400;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.i-load-more {
|
||||
width: 65%;
|
||||
font-size: 24rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin: 60rpx auto;
|
||||
}
|
||||
|
||||
.i-load-more-loading {
|
||||
display: inline-block;
|
||||
margin-right: 24rpx;
|
||||
vertical-align: middle;
|
||||
width: 28rpx;
|
||||
height: 28rpx;
|
||||
background: 0 0;
|
||||
border-radius: 50%;
|
||||
border: 4rpx solid #e9eaec;
|
||||
border-color: #e9eaec #e9eaec #e9eaec #2d8cf0;
|
||||
animation: btn-spin 0.6s linear;
|
||||
animation-iteration-count: infinite;
|
||||
}
|
||||
|
||||
.i-load-more-tip {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.i-load-more-line {
|
||||
display: flex;
|
||||
border-top: 0;
|
||||
}
|
||||
|
||||
.i-load-more-line .i-load-more-tip {
|
||||
position: relative;
|
||||
top: -.1em;
|
||||
padding: 0 0.55em;
|
||||
}
|
||||
|
||||
.i-load-more-empty {
|
||||
width: 8rpx;
|
||||
height: 8rpx;
|
||||
border-radius: 50%;
|
||||
background-color: #e5e5e5;
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
vertical-align: 0;
|
||||
top: -.16em;
|
||||
}
|
||||
|
||||
@-webkit-keyframes btn-spin {
|
||||
0% {
|
||||
transform: rotate(0);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes btn-spin {
|
||||
0% {
|
||||
transform: rotate(0);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
/**首页规格弹窗begin ***/
|
||||
.sku-content {
|
||||
position: fixed;
|
||||
bottom: 0px;
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.sku-card {
|
||||
width: 750rpx;
|
||||
box-sizing: border-box;
|
||||
border-radius: 30rpx 30rpx 0 0;
|
||||
background: #fff;
|
||||
overflow: hidden;
|
||||
padding-bottom: constant(safe-area-inset-bottom);
|
||||
|
||||
}
|
||||
|
||||
.sku-card .close {
|
||||
position: absolute;
|
||||
right: 28rpx;
|
||||
top: 28rpx;
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.sku-card .close image {
|
||||
width: 26rpx;
|
||||
height: 26rpx;
|
||||
}
|
||||
|
||||
.sku-card .sku-header {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
margin: 40rpx;
|
||||
}
|
||||
|
||||
.sku-card .sku-header .sku-img {
|
||||
width: 180rpx;
|
||||
height: 180rpx;
|
||||
border-radius: 20rpx;
|
||||
margin-right: 30rpx;
|
||||
box-shadow: 0 0 15rpx rgba(0,0,0,0.1);
|
||||
|
||||
}
|
||||
|
||||
.sku-card .sku-header .sku-img image {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.sku-card .sku-header .sku-desc {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.sku-card .sku-header .sku-desc .sku-title {
|
||||
width: 390rpx;
|
||||
min-height: 60rpx;
|
||||
margin-bottom: 16rpx;
|
||||
color: #444;
|
||||
font-weight: bold;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.sku-card .sku-header .sku-desc .sku-title span {
|
||||
position: absolute;
|
||||
width: 390rpx;
|
||||
height: 60rpx;
|
||||
left: 0;
|
||||
top: 0;
|
||||
font-size: 26rpx;
|
||||
line-height: 31rpx;
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
overflow: hidden;
|
||||
text-overflow: initial;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.sku-card .sku-header .sku-price {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
margin-bottom: 12rpx;
|
||||
font-size: 24rpx;
|
||||
line-height: 24rpx;
|
||||
}
|
||||
|
||||
.sku-card .sku-header .sku-price .sale-price {
|
||||
color: #ff758c;
|
||||
font-family: DIN;
|
||||
margin-right: 12rpx;
|
||||
margin-bottom: -4rpx;
|
||||
}
|
||||
|
||||
.sku-card .sku-header .sku-price .sale-price span {
|
||||
font-size: 56rpx;
|
||||
line-height: 56rpx;
|
||||
margin-left: 8rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.sku-card .sku-header .sku-price .market-price {
|
||||
font-family: DIN;
|
||||
text-decoration: line-through;
|
||||
color: #999;
|
||||
margin-right: 30rpx;
|
||||
}
|
||||
|
||||
.sku-card .sku-header .sku-switch-on {
|
||||
font-size: 24rpx;
|
||||
color: #444;
|
||||
}
|
||||
|
||||
.sku-card .sku-msg {
|
||||
width: 670rpx;
|
||||
margin: 0 auto 60rpx;
|
||||
border-radius: 16rpx;
|
||||
background: linear-gradient(to right,#fff7f0,#fff4ec);
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
padding: 20rpx;
|
||||
color: #4facfe;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.sku-card .sku-msg .tag {
|
||||
border-radius: 16rpx;
|
||||
border: 1rpx solid #4facfe;
|
||||
font-size: 20rpx;
|
||||
line-height: 28rpx;
|
||||
font-weight: 500;
|
||||
padding: 0 8rpx;
|
||||
margin-right: 8rpx;
|
||||
color: #4facfe;
|
||||
white-space: nowrap;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.sku-card .sku-msg .sku-activity-msg {
|
||||
color: #ca7e57;
|
||||
font-size: 24rpx;
|
||||
line-height: 32rpx;
|
||||
width: 540rpx;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.sku-card .sku-spec {
|
||||
width: 670rpx;
|
||||
margin: 0 auto 40rpx;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.sku-card .sku-spec .title {
|
||||
font-size: 26rpx;
|
||||
line-height: 50rpx;
|
||||
margin-right: 8rpx;
|
||||
}
|
||||
|
||||
.sku-card .sku-spec .spec-list {
|
||||
width: 600rpx;
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.sku-card .sku-spec .spec-list span {
|
||||
position: relative;
|
||||
height: 46rpx;
|
||||
background: #f6f6f6;
|
||||
border: 2rpx solid #f6f6f6;
|
||||
text-align: center;
|
||||
line-height: 46rpx;
|
||||
font-size: 26rpx;
|
||||
margin: 0 8rpx 20rpx 0;
|
||||
color: #666;
|
||||
border-radius: 46rpx;
|
||||
padding: 0 30rpx;
|
||||
display: block;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.sku-card .sku-spec .spec-list .on {
|
||||
border-color: #00f2fe;
|
||||
color: #4facfe;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.sku-card .sku-spec .spec-list .disabled {
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.sku-card .sku-num-content {
|
||||
width: 670rpx;
|
||||
margin: 0 auto 26rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.sku-card .sku-num-content .title {
|
||||
width: 80rpx;
|
||||
font-size: 26rpx;
|
||||
line-height: 50rpx;
|
||||
}
|
||||
|
||||
.sku-card .sku-num-content .msg {
|
||||
width: 420rpx;
|
||||
color: #aaa;
|
||||
font-size: 26rpx;
|
||||
line-height: 50rpx;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.sku-card .sku-num-content .even-num {
|
||||
width: 420rpx;
|
||||
color: #4facfe;
|
||||
font-size: 26rpx;
|
||||
line-height: 50rpx;
|
||||
white-space: nowrap;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.sku-card .sku-confirm {
|
||||
width: 750rpx;
|
||||
background: linear-gradient(90deg, #e7614d 0%, #e68475 100%);
|
||||
line-height: 96rpx;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
font-size: 30rpx;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border-radius: 0;
|
||||
font-weight: bold;
|
||||
border-radius: 20px 20px 0px 0px;
|
||||
padding-bottom: calc(env(safe-area-inset-bottom) - 30rpx);
|
||||
}
|
||||
|
||||
.sku-card button.sku-confirm::after{
|
||||
border: 0;
|
||||
}
|
||||
|
||||
.sku-card button[disabled].sku-confirm{
|
||||
background: #f6f6f6;
|
||||
}
|
||||
|
||||
.i-input-number {
|
||||
color: #495060;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.i-input-number view {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.i-input-number view image {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
}
|
||||
|
||||
.i-input-number-minus {
|
||||
border-right: none;
|
||||
border-radius: 4rpx 0 0 4rpx;
|
||||
}
|
||||
|
||||
.i-input-number-plus {
|
||||
border-left: none;
|
||||
border-radius: 0 4rpx 4rpx 0;
|
||||
}
|
||||
|
||||
.i-input-number-text {
|
||||
text-align: center;
|
||||
height: 48rpx;
|
||||
width: 66rpx;
|
||||
font-size: 24rpx;
|
||||
line-height: 48rpx;
|
||||
color: #495060;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
/**首页规格弹出end***/
|
||||
|
||||
.mask {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: #000;
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
z-index: 99;
|
||||
line-height: 80rpx;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
/* 订单提醒begin */
|
||||
.order-notify {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: calc(env(safe-area-inset-top) + 200rpx);
|
||||
z-index: 200;
|
||||
}
|
||||
|
||||
/* 订单提醒end */
|
||||
|
||||
image {
|
||||
will-change: transform;
|
||||
}
|
||||
|
||||
.bgDisabled {
|
||||
background: #ccc!important;
|
||||
}
|
||||
|
||||
/* 安全区域 */
|
||||
.safebottom {
|
||||
padding-bottom: env(safe-area-inset-bottom) !important;
|
||||
/* padding-bottom: 20rpx!important; */
|
||||
}
|
|
@ -0,0 +1,411 @@
|
|||
/* flex */
|
||||
.i-flex {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.i-flex-wrap {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.i-flex-nowrap {
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
.i-flex-col {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.i-flex-item {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.i-flex-alc {
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.i-flex-spb {
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.i-aic {
|
||||
align-items: center!important;
|
||||
}
|
||||
|
||||
.jcontent-c {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.jcontent-sb {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.jcontent-sa {
|
||||
justify-content: space-around;
|
||||
}
|
||||
|
||||
.weight {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.text-overflow1 {
|
||||
overflow: hidden;
|
||||
text-overflow:ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.text-overflow2 {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.text-center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.text-right {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
/* 字体大小 */
|
||||
.fsz-16 {
|
||||
font-size: 16rpx!important;
|
||||
}
|
||||
|
||||
.fsz-22 {
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.fsz-24 {
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.fsz-26 {
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.fsz-28 {
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.fsz-30 {
|
||||
font-size: 30rpx;
|
||||
}
|
||||
|
||||
.fsz-32 {
|
||||
font-size: 32rpx;
|
||||
}
|
||||
|
||||
.fsz-34 {
|
||||
font-size: 34rpx;
|
||||
}
|
||||
|
||||
.fsz-36 {
|
||||
font-size: 36rpx;
|
||||
}
|
||||
|
||||
.fsz-38 {
|
||||
font-size: 38rpx;
|
||||
}
|
||||
|
||||
.fsz-60 {
|
||||
font-size: 60rpx;
|
||||
}
|
||||
|
||||
/* 字体颜色 */
|
||||
.text-3 {
|
||||
color: #333!important;
|
||||
}
|
||||
|
||||
.text-6 {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.text-gray {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.text-white {
|
||||
color: #fff!important;
|
||||
}
|
||||
|
||||
.text-dark {
|
||||
color: #000!important;
|
||||
}
|
||||
|
||||
.text-sucess {
|
||||
color: #5cb85c!important;
|
||||
}
|
||||
|
||||
.text-warning {
|
||||
color: #f0ad4e!important;
|
||||
}
|
||||
|
||||
.red {
|
||||
color: #ff5344;
|
||||
}
|
||||
|
||||
.bule {
|
||||
color: #4facfe;
|
||||
}
|
||||
|
||||
/* 背景 */
|
||||
.bg-f {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.bg-blue {
|
||||
background-color: #4facfe;
|
||||
}
|
||||
|
||||
.bg-primary {
|
||||
background-color: #ff5344;
|
||||
}
|
||||
|
||||
.bg-lighter {
|
||||
background-color: #f8f8f8;
|
||||
}
|
||||
|
||||
.bg-ccc {
|
||||
background: #ccc!important;
|
||||
}
|
||||
|
||||
.bg-sucess {
|
||||
background: #5cb85c!important;
|
||||
}
|
||||
|
||||
.bg-warning {
|
||||
background: #f0ad4e!important;
|
||||
}
|
||||
|
||||
/* 边距 */
|
||||
.ml5 {
|
||||
margin-left: 10rpx;
|
||||
}
|
||||
|
||||
.ml10 {
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
|
||||
.mb5 {
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.mt-auto {
|
||||
margin-top: auto;
|
||||
}
|
||||
|
||||
.mt5 {
|
||||
margin-top: 10rpx;
|
||||
}
|
||||
|
||||
.mx5 {
|
||||
margin-left: 10rpx;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
|
||||
.m10 {
|
||||
margin: 20rpx;
|
||||
}
|
||||
|
||||
.mt10 {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.my10 {
|
||||
margin-top: 10rpx;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.mx10 {
|
||||
margin-left: 20rpx;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.mx15 {
|
||||
margin-left: 30rpx;
|
||||
margin-right: 30rpx;
|
||||
}
|
||||
|
||||
.mb10 {
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.mb20 {
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.m15 {
|
||||
margin: 30rpx;
|
||||
}
|
||||
|
||||
.p5 {
|
||||
padding: 10rpx;
|
||||
}
|
||||
|
||||
.p10 {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.p15 {
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.pt10 {
|
||||
padding-top: 20rpx;
|
||||
}
|
||||
|
||||
.pb10 {
|
||||
padding-bottom: 20rpx!important;
|
||||
}
|
||||
|
||||
.py10 {
|
||||
padding-top: 20rpx!important;
|
||||
padding-bottom: 20rpx!important;
|
||||
}
|
||||
|
||||
.pb15 {
|
||||
padding-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.px15 {
|
||||
padding-left: 30rpx;
|
||||
padding-right: 30rpx;
|
||||
}
|
||||
|
||||
.py15 {
|
||||
padding-top: 30rpx!important;
|
||||
padding-bottom: 30rpx!important;
|
||||
}
|
||||
|
||||
.pb20 {
|
||||
padding-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.p30 {
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.ml30 {
|
||||
margin-left: 30rpx;
|
||||
}
|
||||
|
||||
.pb100 {
|
||||
padding-bottom: 100rpx;
|
||||
}
|
||||
|
||||
.w0 {
|
||||
width: 0;
|
||||
}
|
||||
|
||||
.w90p {
|
||||
width: 90%;
|
||||
}
|
||||
|
||||
.maxH {
|
||||
max-height: 75vh;
|
||||
}
|
||||
|
||||
.rounded-mini {
|
||||
border-radius: 5rpx;
|
||||
}
|
||||
|
||||
.rounded {
|
||||
border-radius: 10rpx;
|
||||
}
|
||||
|
||||
.border-bottom,
|
||||
.border-top {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.border-bottom::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
border-bottom: 1px solid #e5e5e5;
|
||||
transform-origin: 0 0;
|
||||
transform: scaleY(0.5);
|
||||
}
|
||||
|
||||
.border-top::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
right: 0;
|
||||
border-bottom: 1px solid #e5e5e5;
|
||||
transform-origin: 0 0;
|
||||
transform: scaleY(0.5);
|
||||
}
|
||||
|
||||
.btn-hollow {
|
||||
border: 1rpx solid #e5e5e5;
|
||||
padding: 12rpx 20rpx;
|
||||
border-radius: 30rpx;
|
||||
font-size: 22rpx;
|
||||
color: #666;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.line-through {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.line-height {
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
/* 定位 */
|
||||
.pos-r {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.pos-a {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.pos-f {
|
||||
position: fixed;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.shadow {
|
||||
box-shadow: 1px 2px 5px #ccc;
|
||||
}
|
||||
|
||||
.shadow-top {
|
||||
box-shadow: 0px -3px 5px -2px #ccc;
|
||||
}
|
||||
|
||||
.avatar-md {
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
border-radius: 50%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* 边距 字体 */
|
||||
.u-m-l-5{margin-left:5rpx !important}.u-m-l-10{margin-left:10rpx !important}.u-m-l-15{margin-left:15rpx !important}.u-m-l-20{margin-left:20rpx !important}.u-m-l-25{margin-left:25rpx !important}.u-m-l-30{margin-left:30rpx !important}.u-m-l-35{margin-left:35rpx !important}.u-m-l-40{margin-left:40rpx !important}.u-m-l-45{margin-left:45rpx !important}.u-m-l-50{margin-left:50rpx !important}.u-m-l-55{margin-left:55rpx !important}.u-m-l-60{margin-left:60rpx !important}.u-m-t-5{margin-top:5rpx !important}.u-m-t-10{margin-top:10rpx !important}.u-m-t-15{margin-top:15rpx !important}.u-m-t-20{margin-top:20rpx !important}.u-m-t-25{margin-top:25rpx !important}.u-m-t-30{margin-top:30rpx !important}.u-m-t-35{margin-top:35rpx !important}.u-m-t-40{margin-top:40rpx !important}.u-m-t-45{margin-top:45rpx !important}.u-m-t-50{margin-top:50rpx !important}.u-m-t-55{margin-top:55rpx !important}.u-m-t-60{margin-top:60rpx !important}.u-m-r-5{margin-right:5rpx !important}.u-m-r-10{margin-right:10rpx !important}.u-m-r-15{margin-right:15rpx !important}.u-m-r-20{margin-right:20rpx !important}.u-m-r-25{margin-right:25rpx !important}.u-m-r-30{margin-right:30rpx !important}.u-m-r-35{margin-right:35rpx !important}.u-m-r-40{margin-right:40rpx !important}.u-m-r-45{margin-right:45rpx !important}.u-m-r-50{margin-right:50rpx !important}.u-m-r-55{margin-right:55rpx !important}.u-m-r-60{margin-right:60rpx !important}.u-m-b-5{margin-bottom:5rpx !important}.u-m-b-10{margin-bottom:10rpx !important}.u-m-b-15{margin-bottom:15rpx !important}.u-m-b-20{margin-bottom:20rpx !important}.u-m-b-25{margin-bottom:25rpx !important}.u-m-b-30{margin-bottom:30rpx !important}.u-m-b-35{margin-bottom:35rpx !important}.u-m-b-40{margin-bottom:40rpx !important}.u-m-b-45{margin-bottom:45rpx !important}.u-m-b-50{margin-bottom:50rpx !important}.u-m-b-55{margin-bottom:55rpx !important}.u-m-b-60{margin-bottom:60rpx !important}.u-p-l-5{padding-left:5rpx !important}.u-p-l-10{padding-left:10rpx !important}.u-p-l-15{padding-left:15rpx !important}.u-p-l-20{padding-left:20rpx !important}.u-p-l-25{padding-left:25rpx !important}.u-p-l-30{padding-left:30rpx !important}.u-p-l-35{padding-left:35rpx !important}.u-p-l-40{padding-left:40rpx !important}.u-p-l-45{padding-left:45rpx !important}.u-p-l-50{padding-left:50rpx !important}.u-p-l-55{padding-left:55rpx !important}.u-p-l-60{padding-left:60rpx !important}.u-p-t-5{padding-top:5rpx !important}.u-p-t-10{padding-top:10rpx !important}.u-p-t-15{padding-top:15rpx !important}.u-p-t-20{padding-top:20rpx !important}.u-p-t-25{padding-top:25rpx !important}.u-p-t-30{padding-top:30rpx !important}.u-p-t-35{padding-top:35rpx !important}.u-p-t-40{padding-top:40rpx !important}.u-p-t-45{padding-top:45rpx !important}.u-p-t-50{padding-top:50rpx !important}.u-p-t-55{padding-top:55rpx !important}.u-p-t-60{padding-top:60rpx !important}.u-p-r-5{padding-right:5rpx !important}.u-p-r-10{padding-right:10rpx !important}.u-p-r-15{padding-right:15rpx !important}.u-p-r-20{padding-right:20rpx !important}.u-p-r-25{padding-right:25rpx !important}.u-p-r-30{padding-right:30rpx !important}.u-p-r-35{padding-right:35rpx !important}.u-p-r-40{padding-right:40rpx !important}.u-p-r-45{padding-right:45rpx !important}.u-p-r-50{padding-right:50rpx !important}.u-p-r-55{padding-right:55rpx !important}.u-p-r-60{padding-right:60rpx !important}.u-p-b-5{padding-bottom:5rpx !important}.u-p-b-10{padding-bottom:10rpx !important}.u-p-b-15{padding-bottom:15rpx !important}.u-p-b-20{padding-bottom:20rpx !important}.u-p-b-25{padding-bottom:25rpx !important}.u-p-b-30{padding-bottom:30rpx !important}.u-p-b-35{padding-bottom:35rpx !important}.u-p-b-40{padding-bottom:40rpx !important}.u-p-b-45{padding-bottom:45rpx !important}.u-p-b-50{padding-bottom:50rpx !important}.u-p-b-55{padding-bottom:55rpx !important}.u-p-b-60{padding-bottom:60rpx !important}.u-m-5{margin:5rpx !important}.u-m-10{margin:10rpx !important}.u-m-15{margin:15rpx !important}.u-m-20{margin:20rpx !important}.u-m-25{margin:25rpx !important}.u-m-30{margin:30rpx !important}.u-m-35{margin:35rpx !important}.u-m-40{margin:40rpx !important}.u-p-5{padding:5rpx !important}.u-p-10{padding:10rpx !important}.u-p-15{padding:15rpx !important}.u-p-20{padding:20rpx !important}.u-p-25{padding:25rpx !important}.u-p-30{padding:30rpx !important}.u-p-35{padding:35rpx !important}.u-p-40{padding:40rpx !important}.u-font-12{font-size:12rpx !important}.u-font-14{font-size:14rpx !important}.u-font-16{font-size:16rpx !important}.u-font-18{font-size:18rpx !important}.u-font-20{font-size:20rpx !important}.u-font-22{font-size:22rpx !important}.u-font-24{font-size:24rpx !important}.u-font-26{font-size:26rpx !important}.u-font-28{font-size:28rpx !important}.u-font-30{font-size:30rpx !important}.u-font-32{font-size:32rpx !important}.u-font-34{font-size:34rpx !important}.u-font-36{font-size:36rpx !important}.u-font-38{font-size:38rpx !important}.u-font-40{font-size:40rpx !important}
|
||||
/* 边框 */
|
||||
.u-border-bottom,
|
||||
.u-border-left,
|
||||
.u-border-right,
|
||||
.u-border-top,
|
||||
.u-border-top-bottom{position:relative}.u-border-bottom:after,
|
||||
.u-border-left:after,
|
||||
.u-border-right:after,
|
||||
.u-border-top-bottom:after,
|
||||
.u-border-top:after,
|
||||
.u-border:after{content:" ";position:absolute;left:0;top:0;pointer-events:none;box-sizing:border-box;-webkit-transform-origin:0 0;transform-origin:0 0;width:199.8%;height:199.7%;-webkit-transform:scale(.5);transform:scale(.5);border:0 solid #e4e7ed;z-index:2}.u-border-top:after{border-top-width:1px}.u-border-left:after{border-left-width:1px}.u-border-right:after{border-right-width:1px}.u-border-bottom:after{border-bottom-width:1px}.u-border-top-bottom:after{border-width:1px 0}.u-border:after{border-width:1px}
|
|
@ -0,0 +1,91 @@
|
|||
class SEvent {
|
||||
constructor(eventName, isGetEvent) {
|
||||
if (!isGetEvent) {
|
||||
throw 'SEventError:get SEvent instance from SEvent.getEvent!'
|
||||
}
|
||||
this.handlers = []
|
||||
SEvent.events[eventName] = this
|
||||
}
|
||||
|
||||
static getEvent(eventName) {
|
||||
SEvent.events = SEvent.events || {};
|
||||
const keys = Object.keys(SEvent.events)
|
||||
for (const key of keys) {
|
||||
if (key === eventName) {
|
||||
return SEvent.events[key]
|
||||
}
|
||||
|
||||
}
|
||||
return new SEvent(eventName, true)
|
||||
}
|
||||
|
||||
static removeEvent(eventName) {
|
||||
const keys = Object.keys(SEvent.events)
|
||||
for (const key of keys) {
|
||||
if (key === eventName) {
|
||||
SEvent.events[key].handlers = null
|
||||
delete SEvent.events[key]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static off(listenerId){
|
||||
for(const key of Object.keys(SEvent.events)){
|
||||
for(let i=0; i<SEvent.events[key].handlers.length; i++){
|
||||
if (listenerId === SEvent.events[key].handlers[i].id){
|
||||
SEvent.events[key].handlers.splice(i, 1)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
on(handler) {
|
||||
if (handler && typeof (handler) === 'function') {
|
||||
this.handlers.push({
|
||||
id: SEvent.listenerId,
|
||||
handler
|
||||
})
|
||||
return SEvent.listenerId++
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
once(handler){
|
||||
const originHandler = handler
|
||||
handler = (args) => {
|
||||
originHandler(args)
|
||||
this.off(handler)
|
||||
}
|
||||
this.on(handler)
|
||||
}
|
||||
|
||||
emit(args) {
|
||||
if (!(this.handlers && this.handlers.length)) return
|
||||
let l = this.handlers.length
|
||||
let i = 0
|
||||
while(i < this.handlers.length){
|
||||
this.handlers[i++].handler(...arguments)
|
||||
// 防止删除某些once事件的handler导致length改变
|
||||
if (this.handlers.length == l - 1) {
|
||||
i--
|
||||
l--
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
off(handler) {
|
||||
if (!(this.handlers && this.handlers.length)) return
|
||||
for (let i = 0; i < this.handlers.length; i++) {
|
||||
if (this.handlers[i].handler === handler) {
|
||||
this.handlers.splice(i, 1)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
SEvent.listenerId = 1
|
||||
|
||||
module.exports = SEvent
|
||||
|
||||
|
|
@ -0,0 +1,345 @@
|
|||
// 引入事件模块 https://github.com/GravityC/SPage
|
||||
const SEvent = require('SEvent.js')
|
||||
wx.$event = {
|
||||
on(eventName, handler) {
|
||||
return SEvent.getEvent(eventName).on(handler)
|
||||
},
|
||||
once(eventName, handler) {
|
||||
SEvent.getEvent(eventName).once(handler)
|
||||
},
|
||||
emit(eventName) {
|
||||
const args = Array.from(arguments).slice(1)
|
||||
SEvent.getEvent(eventName).emit(...args)
|
||||
},
|
||||
off(nameOrId, handler) {
|
||||
if(handler && typeof (handler) === 'function'){
|
||||
SEvent.getEvent(nameOrId).off(handler)
|
||||
}else{
|
||||
SEvent.off(nameOrId)
|
||||
}
|
||||
},
|
||||
remove(eventName) {
|
||||
SEvent.removeEvent(eventName)
|
||||
}
|
||||
}
|
||||
|
||||
// 引入request模块
|
||||
const SRequest = require('SRequest.js')
|
||||
const $http = new SRequest()
|
||||
wx.$http = $http
|
||||
wx.$request = $http.request.bind($http)
|
||||
wx.$get = $http.get.bind($http)
|
||||
wx.$post = $http.post.bind($http)
|
||||
wx.$put = $http.put.bind($http)
|
||||
wx.$delete = $http.delete.bind($http)
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------------- */
|
||||
wx.$pages = {}
|
||||
// 获取当前页面实例
|
||||
wx.$getCurPage = function() {
|
||||
return getCurrentPages()[getCurrentPages().length - 1]
|
||||
}
|
||||
|
||||
// 获取当前页面实例对应的页面名
|
||||
wx.$getCurPageName = function() {
|
||||
return wx.$getCurPage().$name
|
||||
}
|
||||
|
||||
// $place与$take,$take调用完即删除引用
|
||||
let channel = {}
|
||||
wx.$place = function(id, value) {
|
||||
channel[id] = value
|
||||
}
|
||||
|
||||
wx.$take = function(id) {
|
||||
const v = channel[id]
|
||||
channel[id] = null
|
||||
return v
|
||||
}
|
||||
|
||||
/**
|
||||
* 封装wx.navigateTo
|
||||
* @url {string} - 跳转路径
|
||||
* @query {object} - 携带参数
|
||||
*/
|
||||
wx.$route = function(url, query) {
|
||||
const page = getPage(url)
|
||||
query = query || {}
|
||||
query.from = wx.$getCurPageName() // Page || Component
|
||||
// 若page已加载可调用onNavigate方法
|
||||
if (page && page.onNavigate) {
|
||||
page.onNavigate(query)
|
||||
}
|
||||
url = url + '?' + parseQuery(query)
|
||||
wx.navigateTo({
|
||||
url
|
||||
})
|
||||
}
|
||||
|
||||
// -----------------------------以下是工具函数----------------------
|
||||
|
||||
//装饰器
|
||||
//@afterOrigin {Boolean} - true:装饰函数在原函数之后触发
|
||||
const decorator = function(originFn, decorateFn, afterOrigin) {
|
||||
const origin = originFn
|
||||
originFn = function(args) {
|
||||
if (afterOrigin) {
|
||||
if (origin) origin.call(this, args)
|
||||
decorateFn.call(this, args)
|
||||
} else {
|
||||
decorateFn.call(this, args)
|
||||
if (origin) origin.call(this, args)
|
||||
}
|
||||
}
|
||||
return originFn
|
||||
}
|
||||
|
||||
// 解析query对象成string
|
||||
const parseQuery = function(query) {
|
||||
return Object.keys(query).map(k => `${k}=${query[k]}`).join('&')
|
||||
}
|
||||
|
||||
// 从url中得到pageName
|
||||
const getPageName = function(url) {
|
||||
url = url.includes('?') ? url.split('?')[0] : url
|
||||
const arr = url.split('/')
|
||||
return arr[arr.length - 1]
|
||||
}
|
||||
|
||||
/**
|
||||
* @str - pageName或者url
|
||||
*/
|
||||
const getPage = function(str) {
|
||||
const name = str.includes('/') ? getPageName(str) : str
|
||||
return wx.$pages[name]
|
||||
}
|
||||
|
||||
// 判断是否是空对象
|
||||
const isEmpty = function(obj) {
|
||||
return !Object.keys(obj).length
|
||||
}
|
||||
|
||||
/**
|
||||
* 扩展computed计算属性
|
||||
*/
|
||||
const extendComputed = function(option) {
|
||||
let page
|
||||
// 为$setData方法响应computed
|
||||
option.$setData = function(obj) {
|
||||
this.setData(obj)
|
||||
page = this // 绑定page实例
|
||||
const needUpdate = calcComputed() // 将需要改变的computed属性添加到接下来要setData的对象中
|
||||
if (!isEmpty(needUpdate)) {
|
||||
this.setData(needUpdate)
|
||||
}
|
||||
}
|
||||
|
||||
const computed = option.computed || {}
|
||||
const computedKeys = Object.keys(computed)
|
||||
let computedCache = {}
|
||||
|
||||
// 计算需更改的计算属性
|
||||
const calcComputed = function(isInit) {
|
||||
const needUpdate = {}
|
||||
const that = isInit ? option : page
|
||||
for (const key of computedKeys) {
|
||||
const value = computed[key].call(that)
|
||||
if (value !== computedCache[key]) needUpdate[key] = computedCache[key] = value
|
||||
if (isInit) option.data[key] = needUpdate[key] // 初始化操作
|
||||
}
|
||||
return needUpdate
|
||||
}
|
||||
|
||||
// 页面unload时清空computedCache
|
||||
option.onUnload = decorator(option.onUnload, function() {
|
||||
computedCache = {}
|
||||
})
|
||||
|
||||
calcComputed(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 为所有Page和Component扩展方法
|
||||
*/
|
||||
const extendFunctions = function(option) {
|
||||
option.$route = wx.$route
|
||||
option.$place = wx.$place
|
||||
option.$take = wx.$take
|
||||
// 封装wx.request
|
||||
option.$request = wx.$request
|
||||
option.$get = wx.$get
|
||||
option.$post = wx.$post
|
||||
option.$put = wx.$put
|
||||
option.$delete = wx.$delete
|
||||
// 事件机制
|
||||
option.$on = function(eventName, handler){
|
||||
this.$listeners = this.$listeners || []
|
||||
this.$listeners.push(wx.$event.on(eventName, handler))
|
||||
}
|
||||
option.$once = wx.$event.once
|
||||
option.$emit = wx.$event.emit
|
||||
option.$off = wx.$event.off
|
||||
option.$remove = wx.$event.remove
|
||||
}
|
||||
|
||||
/**
|
||||
* -------------扩展App-------------------
|
||||
*/
|
||||
let initPageObject
|
||||
let initCompObject
|
||||
const extendApp = function() {
|
||||
const originApp = App
|
||||
App = function(option) {
|
||||
if (option.$mixinP) {
|
||||
initPageObject = option.$mixinP
|
||||
}
|
||||
|
||||
if (option.$mixinC) {
|
||||
initCompObject = option.$mixinC
|
||||
}
|
||||
|
||||
originApp(option)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* -------------扩展Page----------------
|
||||
*/
|
||||
const extendPage = function() {
|
||||
const originPage = Page
|
||||
Page = function(option) {
|
||||
// 混合app.$mixinP
|
||||
if (initPageObject) {
|
||||
const hooks = ['onLoad', 'onShow', 'onReady', 'onHide', 'onUnload', 'onPullDownRefresh', 'onReachBottom', 'onShareAppMessage', 'onPageScroll', 'onResize', 'onTabItemTap']
|
||||
for (const k in initPageObject) {
|
||||
if (hooks.includes(k)) {
|
||||
option[k] = decorator(option[k], initPageObject[k])
|
||||
} else if (k === 'data') {
|
||||
option.data = Object.assign({}, initPageObject.data, option.data)
|
||||
} else if (!option.hasOwnProperty(k)) {
|
||||
option[k] = initPageObject[k]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 若定义了$name, 则添加到wx.$pages中
|
||||
if (option.$name) {
|
||||
wx.$pages[option.$name] = option
|
||||
} else {
|
||||
option.$name = 'unKnow' //此处强行给$name赋值,为了后续区分是Page还是Component
|
||||
}
|
||||
|
||||
// 添加$status属性
|
||||
option.$status = {
|
||||
isFirstShow: true
|
||||
}
|
||||
// 是否已执行过onNavigate函数
|
||||
option.$$isNavigated = false
|
||||
|
||||
// 扩展computed属性
|
||||
extendComputed(option)
|
||||
// 扩展方法
|
||||
extendFunctions(option)
|
||||
|
||||
// 装饰onNavigate
|
||||
option.onNavigate = decorator(option.onNavigate, function(query) {
|
||||
option.$$isNavigated = true
|
||||
})
|
||||
|
||||
// 装饰onLoad
|
||||
option.onLoad = decorator(option.onLoad, function(query) {
|
||||
// 若页面有onNavigate方法但还没运行,则运行onNavigate方法
|
||||
if (option.onNavigate && !option.$$isNavigated) {
|
||||
option.onNavigate(query)
|
||||
}
|
||||
})
|
||||
|
||||
// 装饰onShow
|
||||
option.onShow = decorator(option.onShow, function() {
|
||||
this.$status.isFirstShow = false
|
||||
}, true)
|
||||
|
||||
// 隐藏页面时隐藏标题栏加载动画(坑爹的微信官方bug)
|
||||
option.onHide = decorator(option.onHide, function() {
|
||||
wx.hideNavigationBarLoading()
|
||||
})
|
||||
|
||||
// 装饰onUnload
|
||||
option.onUnload = decorator(option.onUnload, function(){
|
||||
// 卸载本页面的监听器
|
||||
if (this.$listeners && this.$listeners.length) {
|
||||
for (const id of this.$listeners) {
|
||||
wx.$event.off(id)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
//原生Page构造
|
||||
originPage(option)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* --------------------------------------------扩展Component
|
||||
*/
|
||||
const extendComponent = function() {
|
||||
const originComponent = Component
|
||||
Component = function(option) {
|
||||
option.methods = option.methods || {}
|
||||
// 混合app.$mixinC
|
||||
if (initCompObject) {
|
||||
const mixinObj = ['properties', 'data', 'observers', 'methods', 'options']
|
||||
for (const k in initCompObject) {
|
||||
if (k === 'lifetimes' || k === 'pageLifetimes') {
|
||||
if (!option[k]) {
|
||||
option[k] = initCompObject[k]
|
||||
} else {
|
||||
for (const h in initCompObject[k]) {
|
||||
option[k][h] = decorator(option[k][h], initCompObject[k][h])
|
||||
}
|
||||
}
|
||||
} else if (mixinObj.includes(k)) {
|
||||
option[k] = Object.assign({}, initCompObject[k], option[k])
|
||||
} else if (!option.hasOwnProperty(k)) {
|
||||
option[k] = initCompObject[k]
|
||||
}
|
||||
}
|
||||
}
|
||||
// 扩展computed属性
|
||||
extendComputed(option)
|
||||
// 扩展方法
|
||||
extendFunctions(option.methods)
|
||||
|
||||
option.lifetimes = option.lifetimes || {}
|
||||
// 装饰detached
|
||||
option.lifetimes.detached = decorator(option.lifetimes.detached, function () {
|
||||
// 卸载本组件的监听器
|
||||
if (this.$listeners && this.$listeners.length) {
|
||||
for (const id of this.$listeners) {
|
||||
wx.$event.off(id)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// 获取当前页面实例
|
||||
option.methods.$getCurPage = wx.$getCurPage
|
||||
|
||||
// 获取当前页面实例对应的页面名
|
||||
option.methods.$getCurPageName = wx.$getCurPageName
|
||||
|
||||
// 重新定义$setData,便于扩展其他功能
|
||||
const originData = option.$setData
|
||||
option.methods.$setData = function(obj) {
|
||||
return originData.call(this, obj)
|
||||
}
|
||||
//原生Component构造
|
||||
originComponent(option)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = (function() {
|
||||
extendApp()
|
||||
extendPage()
|
||||
extendComponent()
|
||||
}())
|
|
@ -0,0 +1,124 @@
|
|||
class Interceptor {
|
||||
handlerId = 1
|
||||
|
||||
constructor() {
|
||||
this.id = Interceptor.id++
|
||||
this.handlers = []
|
||||
}
|
||||
|
||||
use(success, fail) {
|
||||
this.handlers.push({
|
||||
id: this.handlerId,
|
||||
success,
|
||||
fail
|
||||
})
|
||||
return this.handlerId++
|
||||
}
|
||||
|
||||
eject(handlerId) {
|
||||
for (let i = 0; i < this.handlers.length; i++) {
|
||||
if (this.handlers[i].id === handlerId) {
|
||||
return this.handlers.splice(i, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
go(config, isSuccess) {
|
||||
if(!isSuccess){
|
||||
return this.handlers[0].fail(config)
|
||||
}else{
|
||||
for (const v of this.handlers) {
|
||||
config = v.success(config)
|
||||
}
|
||||
return config
|
||||
}
|
||||
}
|
||||
}
|
||||
Interceptor.id = 1
|
||||
|
||||
function isHttpSuccess(status){
|
||||
return status >= 200 && status < 300 || status === 304
|
||||
}
|
||||
|
||||
class SRequest {
|
||||
config = {
|
||||
baseUrl:'',
|
||||
dataType: 'json',
|
||||
responseType: 'text',
|
||||
header: {},
|
||||
}
|
||||
|
||||
constructor(config) {
|
||||
this.config = Object.assign(this.config, config)
|
||||
this.interceptors = {
|
||||
request: new Interceptor(),
|
||||
response: new Interceptor()
|
||||
}
|
||||
}
|
||||
|
||||
request(config) {
|
||||
config = config ? Object.assign({}, this.config, config) : this.config
|
||||
config = this.interceptReq(config, true)
|
||||
|
||||
let { url, method, data, header, dataType, responseType } = config
|
||||
if (!url.startsWith('https://')) {
|
||||
url = config.baseUrl + url
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
wx.request({
|
||||
url,
|
||||
data,
|
||||
header: header || this.header,
|
||||
method,
|
||||
dataType,
|
||||
responseType,
|
||||
success: res => {
|
||||
if(isHttpSuccess(res.statusCode)){
|
||||
res = this.interceptRes(res, true)
|
||||
resolve(res.data)
|
||||
}else{
|
||||
res = this.interceptRes(res, false)
|
||||
reject(res)
|
||||
}
|
||||
},
|
||||
fail: res => {
|
||||
res = this.interceptRes(res, false)
|
||||
reject(res)
|
||||
},
|
||||
})
|
||||
})
|
||||
}
|
||||
// 遍历请求拦截器
|
||||
interceptReq(config, isSuccess) {
|
||||
return this.interceptors.request.go(config, isSuccess)
|
||||
}
|
||||
|
||||
// 遍历响应拦截器
|
||||
interceptRes(response, isSuccess) {
|
||||
return this.interceptors.response.go(response, isSuccess)
|
||||
}
|
||||
|
||||
get(url, config) {
|
||||
const options = { url, method: 'GET' }
|
||||
Object.assign(options, config || null)
|
||||
return this.request(options)
|
||||
}
|
||||
|
||||
post(url, data, config) {
|
||||
const options = { url, method: 'POST' }
|
||||
Object.assign(options, data ? { data } : null, config || null)
|
||||
return this.request(options)
|
||||
}
|
||||
put(url, data, config) {
|
||||
const options = { url, method: 'PUT' }
|
||||
Object.assign(options, data ? { data } : null, config || null)
|
||||
return this.request(options)
|
||||
}
|
||||
delete(url, config) {
|
||||
const options = { url, method: 'DELETE' }
|
||||
Object.assign(options, config || null)
|
||||
return this.request(options)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = SRequest
|
|
@ -0,0 +1,93 @@
|
|||
function base64_encode(str) {
|
||||
var c1, c2, c3;
|
||||
var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
var i = 0, len = str.length, string = '';
|
||||
|
||||
while (i < len) {
|
||||
c1 = str.charCodeAt(i++) & 0xff;
|
||||
if (i == len) {
|
||||
string += base64EncodeChars.charAt(c1 >> 2);
|
||||
string += base64EncodeChars.charAt((c1 & 0x3) << 4);
|
||||
string += "==";
|
||||
break;
|
||||
}
|
||||
c2 = str.charCodeAt(i++);
|
||||
if (i == len) {
|
||||
string += base64EncodeChars.charAt(c1 >> 2);
|
||||
string += base64EncodeChars.charAt(((c1 & 0x3) << 4)
|
||||
| ((c2 & 0xF0) >> 4));
|
||||
string += base64EncodeChars.charAt((c2 & 0xF) << 2);
|
||||
string += "=";
|
||||
break;
|
||||
}
|
||||
c3 = str.charCodeAt(i++);
|
||||
string += base64EncodeChars.charAt(c1 >> 2);
|
||||
string += base64EncodeChars.charAt(((c1 & 0x3) << 4)
|
||||
| ((c2 & 0xF0) >> 4));
|
||||
string += base64EncodeChars.charAt(((c2 & 0xF) << 2)
|
||||
| ((c3 & 0xC0) >> 6));
|
||||
string += base64EncodeChars.charAt(c3 & 0x3F)
|
||||
}
|
||||
return string
|
||||
}
|
||||
|
||||
function base64_decode(str) {
|
||||
var c1, c2, c3, c4;
|
||||
var base64DecodeChars = new Array(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62,
|
||||
-1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1,
|
||||
-1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
|
||||
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1,
|
||||
26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
|
||||
43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1);
|
||||
var i = 0, len = str.length, string = '';
|
||||
|
||||
while (i < len) {
|
||||
do {
|
||||
c1 = base64DecodeChars[str.charCodeAt(i++) & 0xff]
|
||||
} while (i < len && c1 == -1);
|
||||
|
||||
if (c1 == -1)
|
||||
break;
|
||||
|
||||
do {
|
||||
c2 = base64DecodeChars[str.charCodeAt(i++) & 0xff]
|
||||
} while (i < len && c2 == -1);
|
||||
|
||||
if (c2 == -1)
|
||||
break;
|
||||
|
||||
string += String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4));
|
||||
|
||||
do {
|
||||
c3 = str.charCodeAt(i++) & 0xff;
|
||||
if (c3 == 61)
|
||||
return string;
|
||||
|
||||
c3 = base64DecodeChars[c3]
|
||||
} while (i < len && c3 == -1);
|
||||
|
||||
if (c3 == -1)
|
||||
break;
|
||||
|
||||
string += String.fromCharCode(((c2 & 0XF) << 4) | ((c3 & 0x3C) >> 2));
|
||||
|
||||
do {
|
||||
c4 = str.charCodeAt(i++) & 0xff;
|
||||
if (c4 == 61)
|
||||
return string;
|
||||
c4 = base64DecodeChars[c4]
|
||||
} while (i < len && c4 == -1);
|
||||
|
||||
if (c4 == -1)
|
||||
break;
|
||||
|
||||
string += String.fromCharCode(((c3 & 0x03) << 6) | c4)
|
||||
}
|
||||
return string;
|
||||
}
|
||||
module.exports = {
|
||||
'base64_encode': base64_encode,
|
||||
'base64_decode': base64_decode
|
||||
};
|
|
@ -0,0 +1,273 @@
|
|||
/*
|
||||
* JavaScript MD5
|
||||
* https://github.com/blueimp/JavaScript-MD5
|
||||
*
|
||||
* Copyright 2011, Sebastian Tschan
|
||||
* https://blueimp.net
|
||||
*
|
||||
* Licensed under the MIT license:
|
||||
* http://www.opensource.org/licenses/MIT
|
||||
*
|
||||
* Based on
|
||||
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
|
||||
* Digest Algorithm, as defined in RFC 1321.
|
||||
* Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
|
||||
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
|
||||
* Distributed under the BSD License
|
||||
* See http://pajhome.org.uk/crypt/md5 for more info.
|
||||
*/
|
||||
|
||||
/*global unescape, define, module */
|
||||
|
||||
; (function ($) {
|
||||
'use strict'
|
||||
|
||||
/*
|
||||
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
|
||||
* to work around bugs in some JS interpreters.
|
||||
*/
|
||||
function safe_add(x, y) {
|
||||
var lsw = (x & 0xFFFF) + (y & 0xFFFF)
|
||||
var msw = (x >> 16) + (y >> 16) + (lsw >> 16)
|
||||
return (msw << 16) | (lsw & 0xFFFF)
|
||||
}
|
||||
|
||||
/*
|
||||
* Bitwise rotate a 32-bit number to the left.
|
||||
*/
|
||||
function bit_rol(num, cnt) {
|
||||
return (num << cnt) | (num >>> (32 - cnt))
|
||||
}
|
||||
|
||||
/*
|
||||
* These functions implement the four basic operations the algorithm uses.
|
||||
*/
|
||||
function md5_cmn(q, a, b, x, s, t) {
|
||||
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b)
|
||||
}
|
||||
function md5_ff(a, b, c, d, x, s, t) {
|
||||
return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t)
|
||||
}
|
||||
function md5_gg(a, b, c, d, x, s, t) {
|
||||
return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t)
|
||||
}
|
||||
function md5_hh(a, b, c, d, x, s, t) {
|
||||
return md5_cmn(b ^ c ^ d, a, b, x, s, t)
|
||||
}
|
||||
function md5_ii(a, b, c, d, x, s, t) {
|
||||
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t)
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the MD5 of an array of little-endian words, and a bit length.
|
||||
*/
|
||||
function binl_md5(x, len) {
|
||||
/* append padding */
|
||||
x[len >> 5] |= 0x80 << (len % 32)
|
||||
x[(((len + 64) >>> 9) << 4) + 14] = len
|
||||
|
||||
var i
|
||||
var olda
|
||||
var oldb
|
||||
var oldc
|
||||
var oldd
|
||||
var a = 1732584193
|
||||
var b = -271733879
|
||||
var c = -1732584194
|
||||
var d = 271733878
|
||||
|
||||
for (i = 0; i < x.length; i += 16) {
|
||||
olda = a
|
||||
oldb = b
|
||||
oldc = c
|
||||
oldd = d
|
||||
|
||||
a = md5_ff(a, b, c, d, x[i], 7, -680876936)
|
||||
d = md5_ff(d, a, b, c, x[i + 1], 12, -389564586)
|
||||
c = md5_ff(c, d, a, b, x[i + 2], 17, 606105819)
|
||||
b = md5_ff(b, c, d, a, x[i + 3], 22, -1044525330)
|
||||
a = md5_ff(a, b, c, d, x[i + 4], 7, -176418897)
|
||||
d = md5_ff(d, a, b, c, x[i + 5], 12, 1200080426)
|
||||
c = md5_ff(c, d, a, b, x[i + 6], 17, -1473231341)
|
||||
b = md5_ff(b, c, d, a, x[i + 7], 22, -45705983)
|
||||
a = md5_ff(a, b, c, d, x[i + 8], 7, 1770035416)
|
||||
d = md5_ff(d, a, b, c, x[i + 9], 12, -1958414417)
|
||||
c = md5_ff(c, d, a, b, x[i + 10], 17, -42063)
|
||||
b = md5_ff(b, c, d, a, x[i + 11], 22, -1990404162)
|
||||
a = md5_ff(a, b, c, d, x[i + 12], 7, 1804603682)
|
||||
d = md5_ff(d, a, b, c, x[i + 13], 12, -40341101)
|
||||
c = md5_ff(c, d, a, b, x[i + 14], 17, -1502002290)
|
||||
b = md5_ff(b, c, d, a, x[i + 15], 22, 1236535329)
|
||||
|
||||
a = md5_gg(a, b, c, d, x[i + 1], 5, -165796510)
|
||||
d = md5_gg(d, a, b, c, x[i + 6], 9, -1069501632)
|
||||
c = md5_gg(c, d, a, b, x[i + 11], 14, 643717713)
|
||||
b = md5_gg(b, c, d, a, x[i], 20, -373897302)
|
||||
a = md5_gg(a, b, c, d, x[i + 5], 5, -701558691)
|
||||
d = md5_gg(d, a, b, c, x[i + 10], 9, 38016083)
|
||||
c = md5_gg(c, d, a, b, x[i + 15], 14, -660478335)
|
||||
b = md5_gg(b, c, d, a, x[i + 4], 20, -405537848)
|
||||
a = md5_gg(a, b, c, d, x[i + 9], 5, 568446438)
|
||||
d = md5_gg(d, a, b, c, x[i + 14], 9, -1019803690)
|
||||
c = md5_gg(c, d, a, b, x[i + 3], 14, -187363961)
|
||||
b = md5_gg(b, c, d, a, x[i + 8], 20, 1163531501)
|
||||
a = md5_gg(a, b, c, d, x[i + 13], 5, -1444681467)
|
||||
d = md5_gg(d, a, b, c, x[i + 2], 9, -51403784)
|
||||
c = md5_gg(c, d, a, b, x[i + 7], 14, 1735328473)
|
||||
b = md5_gg(b, c, d, a, x[i + 12], 20, -1926607734)
|
||||
|
||||
a = md5_hh(a, b, c, d, x[i + 5], 4, -378558)
|
||||
d = md5_hh(d, a, b, c, x[i + 8], 11, -2022574463)
|
||||
c = md5_hh(c, d, a, b, x[i + 11], 16, 1839030562)
|
||||
b = md5_hh(b, c, d, a, x[i + 14], 23, -35309556)
|
||||
a = md5_hh(a, b, c, d, x[i + 1], 4, -1530992060)
|
||||
d = md5_hh(d, a, b, c, x[i + 4], 11, 1272893353)
|
||||
c = md5_hh(c, d, a, b, x[i + 7], 16, -155497632)
|
||||
b = md5_hh(b, c, d, a, x[i + 10], 23, -1094730640)
|
||||
a = md5_hh(a, b, c, d, x[i + 13], 4, 681279174)
|
||||
d = md5_hh(d, a, b, c, x[i], 11, -358537222)
|
||||
c = md5_hh(c, d, a, b, x[i + 3], 16, -722521979)
|
||||
b = md5_hh(b, c, d, a, x[i + 6], 23, 76029189)
|
||||
a = md5_hh(a, b, c, d, x[i + 9], 4, -640364487)
|
||||
d = md5_hh(d, a, b, c, x[i + 12], 11, -421815835)
|
||||
c = md5_hh(c, d, a, b, x[i + 15], 16, 530742520)
|
||||
b = md5_hh(b, c, d, a, x[i + 2], 23, -995338651)
|
||||
|
||||
a = md5_ii(a, b, c, d, x[i], 6, -198630844)
|
||||
d = md5_ii(d, a, b, c, x[i + 7], 10, 1126891415)
|
||||
c = md5_ii(c, d, a, b, x[i + 14], 15, -1416354905)
|
||||
b = md5_ii(b, c, d, a, x[i + 5], 21, -57434055)
|
||||
a = md5_ii(a, b, c, d, x[i + 12], 6, 1700485571)
|
||||
d = md5_ii(d, a, b, c, x[i + 3], 10, -1894986606)
|
||||
c = md5_ii(c, d, a, b, x[i + 10], 15, -1051523)
|
||||
b = md5_ii(b, c, d, a, x[i + 1], 21, -2054922799)
|
||||
a = md5_ii(a, b, c, d, x[i + 8], 6, 1873313359)
|
||||
d = md5_ii(d, a, b, c, x[i + 15], 10, -30611744)
|
||||
c = md5_ii(c, d, a, b, x[i + 6], 15, -1560198380)
|
||||
b = md5_ii(b, c, d, a, x[i + 13], 21, 1309151649)
|
||||
a = md5_ii(a, b, c, d, x[i + 4], 6, -145523070)
|
||||
d = md5_ii(d, a, b, c, x[i + 11], 10, -1120210379)
|
||||
c = md5_ii(c, d, a, b, x[i + 2], 15, 718787259)
|
||||
b = md5_ii(b, c, d, a, x[i + 9], 21, -343485551)
|
||||
|
||||
a = safe_add(a, olda)
|
||||
b = safe_add(b, oldb)
|
||||
c = safe_add(c, oldc)
|
||||
d = safe_add(d, oldd)
|
||||
}
|
||||
return [a, b, c, d]
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an array of little-endian words to a string
|
||||
*/
|
||||
function binl2rstr(input) {
|
||||
var i
|
||||
var output = ''
|
||||
var length32 = input.length * 32
|
||||
for (i = 0; i < length32; i += 8) {
|
||||
output += String.fromCharCode((input[i >> 5] >>> (i % 32)) & 0xFF)
|
||||
}
|
||||
return output
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a raw string to an array of little-endian words
|
||||
* Characters >255 have their high-byte silently ignored.
|
||||
*/
|
||||
function rstr2binl(input) {
|
||||
var i
|
||||
var output = []
|
||||
output[(input.length >> 2) - 1] = undefined
|
||||
for (i = 0; i < output.length; i += 1) {
|
||||
output[i] = 0
|
||||
}
|
||||
var length8 = input.length * 8
|
||||
for (i = 0; i < length8; i += 8) {
|
||||
output[i >> 5] |= (input.charCodeAt(i / 8) & 0xFF) << (i % 32)
|
||||
}
|
||||
return output
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the MD5 of a raw string
|
||||
*/
|
||||
function rstr_md5(s) {
|
||||
return binl2rstr(binl_md5(rstr2binl(s), s.length * 8))
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the HMAC-MD5, of a key and some data (raw strings)
|
||||
*/
|
||||
function rstr_hmac_md5(key, data) {
|
||||
var i
|
||||
var bkey = rstr2binl(key)
|
||||
var ipad = []
|
||||
var opad = []
|
||||
var hash
|
||||
ipad[15] = opad[15] = undefined
|
||||
if (bkey.length > 16) {
|
||||
bkey = binl_md5(bkey, key.length * 8)
|
||||
}
|
||||
for (i = 0; i < 16; i += 1) {
|
||||
ipad[i] = bkey[i] ^ 0x36363636
|
||||
opad[i] = bkey[i] ^ 0x5C5C5C5C
|
||||
}
|
||||
hash = binl_md5(ipad.concat(rstr2binl(data)), 512 + data.length * 8)
|
||||
return binl2rstr(binl_md5(opad.concat(hash), 512 + 128))
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a raw string to a hex string
|
||||
*/
|
||||
function rstr2hex(input) {
|
||||
var hex_tab = '0123456789abcdef'
|
||||
var output = ''
|
||||
var x
|
||||
var i
|
||||
for (i = 0; i < input.length; i += 1) {
|
||||
x = input.charCodeAt(i)
|
||||
output += hex_tab.charAt((x >>> 4) & 0x0F) +
|
||||
hex_tab.charAt(x & 0x0F)
|
||||
}
|
||||
return output
|
||||
}
|
||||
|
||||
/*
|
||||
* Encode a string as utf-8
|
||||
*/
|
||||
function str2rstr_utf8(input) {
|
||||
return unescape(encodeURIComponent(input))
|
||||
}
|
||||
|
||||
/*
|
||||
* Take string arguments and return either raw or hex encoded strings
|
||||
*/
|
||||
function raw_md5(s) {
|
||||
return rstr_md5(str2rstr_utf8(s))
|
||||
}
|
||||
function hex_md5(s) {
|
||||
return rstr2hex(raw_md5(s))
|
||||
}
|
||||
function raw_hmac_md5(k, d) {
|
||||
return rstr_hmac_md5(str2rstr_utf8(k), str2rstr_utf8(d))
|
||||
}
|
||||
function hex_hmac_md5(k, d) {
|
||||
return rstr2hex(raw_hmac_md5(k, d))
|
||||
}
|
||||
|
||||
function md5(string, key, raw) {
|
||||
if (!key) {
|
||||
if (!raw) {
|
||||
return hex_md5(string)
|
||||
}
|
||||
return raw_md5(string)
|
||||
}
|
||||
if (!raw) {
|
||||
return hex_hmac_md5(key, string)
|
||||
}
|
||||
return raw_hmac_md5(key, string)
|
||||
}
|
||||
|
||||
module.exports = md5;
|
||||
}(this))
|
|
@ -0,0 +1,14 @@
|
|||
var MTA_CONFIG={app_id:"",event_id:"",api_base:"https://pingtas.qq.com/pingd",prefix:"_mta_",version:"1.3.10",stat_share_app:!1,stat_pull_down_fresh:!1,stat_reach_bottom:!1,stat_param:!0};function getNetworkType(a){wx.getNetworkType({success:function(b){a(b.networkType)}})}
|
||||
function getSystemInfo(){var a=wx.getSystemInfoSync();return{adt:encodeURIComponent(a.model),scl:a.pixelRatio,scr:a.windowWidth+"x"+a.windowHeight,lg:a.language,fl:a.version,jv:encodeURIComponent(a.system),tz:encodeURIComponent(a.platform)}}function getUID(){try{return wx.getStorageSync(MTA_CONFIG.prefix+"auid")}catch(a){}}function setUID(){try{var a=getRandom();wx.setStorageSync(MTA_CONFIG.prefix+"auid",a);return a}catch(b){}}
|
||||
function getSID(){try{return wx.getStorageSync(MTA_CONFIG.prefix+"ssid")}catch(a){}}function setSID(){try{var a="s"+getRandom();wx.setStorageSync(MTA_CONFIG.prefix+"ssid",a);return a}catch(b){}}function getRandom(a){for(var b=[0,1,2,3,4,5,6,7,8,9],c=10;1<c;c--){var d=Math.floor(10*Math.random()),f=b[d];b[d]=b[c-1];b[c-1]=f}for(c=d=0;5>c;c++)d=10*d+b[c];return(a||"")+(d+""+ +new Date)}
|
||||
function getPagePath(){try{var a=getCurrentPages(),b="/";0<a.length&&(b=a.pop().__route__);return b}catch(c){console.log("get current page path error:"+c)}}function getMainInfo(){var a={dm:"wechat.apps.xx",url:encodeURIComponent(getPagePath()+getQuery(MTA.Data.pageQuery)),pvi:"",si:"",ty:0};a.pvi=function(){var b=getUID();b||(b=setUID(),a.ty=1);return b}();a.si=function(){var a=getSID();a||(a=setSID());return a}();return a}
|
||||
function getBasicInfo(){var a=getSystemInfo();getNetworkType(function(a){try{wx.setStorageSync(MTA_CONFIG.prefix+"ntdata",a)}catch(c){}});a.ct=wx.getStorageSync(MTA_CONFIG.prefix+"ntdata")||"4g";return a}function getExtentInfo(){var a=MTA.Data.userInfo;var b=[],c;for(c in a)a.hasOwnProperty(c)&&b.push(c+"="+a[c]);a=b.join(";");return{r2:MTA_CONFIG.app_id,r4:"wx",ext:"v="+MTA_CONFIG.version+(null!==a&&""!==a?";ui="+encodeURIComponent(a):"")}}
|
||||
function getQuery(a){if(!MTA_CONFIG.stat_param||!a)return"";a=ignoreParams(a);var b=[],c;for(c in a)b.push(c+"="+a[c]);return 0<b.length?"?"+b.join("&"):""}function ignoreParams(a){if(1>MTA_CONFIG.ignore_params.length)return a;var b={},c;for(c in a)0<=MTA_CONFIG.ignore_params.indexOf(c)||(b[c]=a[c]);return b}
|
||||
function initOnload(){var a=Page;Page=function(b){var c=b.onLoad;b.onLoad=function(a){c&&c.call(this,a);MTA.Data.lastPageQuery=MTA.Data.pageQuery;MTA.Data.pageQuery=a;MTA.Data.lastPageUrl=MTA.Data.pageUrl;MTA.Data.pageUrl=getPagePath();MTA.Data.show=!1;MTA.Page.init()};a(b)}}
|
||||
var MTA={App:{init:function(a){"appID"in a&&(MTA_CONFIG.app_id=a.appID);"eventID"in a&&(MTA_CONFIG.event_id=a.eventID);"statShareApp"in a&&(MTA_CONFIG.stat_share_app=a.statShareApp);"statPullDownFresh"in a&&(MTA_CONFIG.stat_pull_down_fresh=a.statPullDownFresh);"statReachBottom"in a&&(MTA_CONFIG.stat_reach_bottom=a.statReachBottom);"ignoreParams"in a&&(MTA_CONFIG.ignore_params=a.ignoreParams);"statParam"in a&&(MTA_CONFIG.stat_param=a.statParam);setSID();try{"lauchOpts"in a&&(MTA.Data.lanchInfo=a.lauchOpts,
|
||||
MTA.Data.lanchInfo.landing=1)}catch(b){}"autoReport"in a&&a.autoReport&&initOnload()}},Page:{init:function(){var a=getCurrentPages()[getCurrentPages().length-1];a.onShow&&!function(){var b=a.onShow;a.onShow=function(){if(!0===MTA.Data.show){var a=MTA.Data.lastPageQuery;MTA.Data.lastPageQuery=MTA.Data.pageQuery;MTA.Data.pageQuery=a;MTA.Data.lastPageUrl=MTA.Data.pageUrl;MTA.Data.pageUrl=getPagePath()}MTA.Data.show=!0;MTA.Page.stat();b.apply(this,arguments)}}();MTA_CONFIG.stat_pull_down_fresh&&a.onPullDownRefresh&&
|
||||
!function(){var b=a.onPullDownRefresh;a.onPullDownRefresh=function(){MTA.Event.stat(MTA_CONFIG.prefix+"pulldownfresh",{url:a.__route__});b.apply(this,arguments)}}();MTA_CONFIG.stat_reach_bottom&&a.onReachBottom&&!function(){var b=a.onReachBottom;a.onReachBottom=function(){MTA.Event.stat(MTA_CONFIG.prefix+"reachbottom",{url:a.__route__});b.apply(this,arguments)}}();MTA_CONFIG.stat_share_app&&a.onShareAppMessage&&!function(){var b=a.onShareAppMessage;a.onShareAppMessage=function(){MTA.Event.stat(MTA_CONFIG.prefix+
|
||||
"shareapp",{url:a.__route__});return b.apply(this,arguments)}}()},multiStat:function(a,b){if(1==b)MTA.Page.stat(a),!0;else{var c=getCurrentPages()[getCurrentPages().length-1];c.onShow&&!function(){var b=c.onShow;c.onShow=function(){MTA.Page.stat(a);b.call(this,arguments)}}()}},stat:function(a){if(""!=MTA_CONFIG.app_id){var b=[],c=getExtentInfo();a&&(c.r2=a);a=[getMainInfo(),c,getBasicInfo()];if(MTA.Data.lanchInfo){a.push({ht:MTA.Data.lanchInfo.scene});MTA.Data.pageQuery&&MTA.Data.pageQuery._mta_ref_id&&
|
||||
a.push({rarg:MTA.Data.pageQuery._mta_ref_id});try{1==MTA.Data.lanchInfo.landing&&(c.ext+=";lp=1",MTA.Data.lanchInfo.landing=0)}catch(e){}}a.push({rdm:"/",rurl:0>=MTA.Data.lastPageUrl.length?MTA.Data.pageUrl+getQuery(MTA.Data.lastPageQuery):encodeURIComponent(MTA.Data.lastPageUrl+getQuery(MTA.Data.lastPageQuery))});a.push({rand:+new Date});c=0;for(var d=a.length;c<d;c++)for(var f in a[c])a[c].hasOwnProperty(f)&&b.push(f+"="+("undefined"==typeof a[c][f]?"":a[c][f]));wx.request({url:MTA_CONFIG.api_base+
|
||||
"?"+b.join("&").toLowerCase()})}}},Event:{stat:function(a,b){if(""!=MTA_CONFIG.event_id){var c=[],d=getMainInfo(),f=getExtentInfo();d.dm="wxapps.click";d.url=a;f.r2=MTA_CONFIG.event_id;var e="undefined"===typeof b?{}:b;var k=[],g;for(g in e)e.hasOwnProperty(g)&&k.push(encodeURIComponent(g)+"="+encodeURIComponent(e[g]));e=k.join(";");f.r5=e;e=0;d=[d,f,getBasicInfo(),{rand:+new Date}];for(f=d.length;e<f;e++)for(var h in d[e])d[e].hasOwnProperty(h)&&c.push(h+"="+("undefined"==typeof d[e][h]?"":d[e][h]));
|
||||
wx.request({url:MTA_CONFIG.api_base+"?"+c.join("&").toLowerCase()})}}},Data:{userInfo:null,lanchInfo:null,pageQuery:null,lastPageQuery:null,pageUrl:"",lastPageUrl:"",show:!1}};module.exports=MTA;
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,883 @@
|
|||
import {
|
||||
base64_encode,
|
||||
base64_decode
|
||||
} from 'base64';
|
||||
import md5 from 'md5';
|
||||
|
||||
var siteInfo = require('../siteinfo.js')
|
||||
|
||||
var util = {};
|
||||
var app = getApp() || {siteInfo: siteInfo};
|
||||
|
||||
util.base64_encode = function(str) {
|
||||
return base64_encode(str)
|
||||
};
|
||||
|
||||
util.base64_decode = function(str) {
|
||||
return base64_decode(str)
|
||||
};
|
||||
|
||||
util.md5 = function(str) {
|
||||
return md5(str)
|
||||
};
|
||||
|
||||
/**
|
||||
构造微擎地址,
|
||||
@params action 微擎系统中的controller, action, do,格式为 'wxapp/home/navs'
|
||||
@params querystring 格式为 {参数名1 : 值1, 参数名2 : 值2}
|
||||
*/
|
||||
util.url = function(action, querystring) {
|
||||
var url = app.siteInfo.siteroot + '?i=' + app.siteInfo.uniacid + '&t=' + app.siteInfo.multiid + '&v=' + app.siteInfo.version + '&from=wxapp&';
|
||||
|
||||
if (action) {
|
||||
action = action.split('/');
|
||||
if (action[0]) {
|
||||
url += 'c=' + action[0] + '&';
|
||||
}
|
||||
if (action[1]) {
|
||||
url += 'a=' + action[1] + '&';
|
||||
}
|
||||
if (action[2]) {
|
||||
url += 'do=' + action[2] + '&';
|
||||
}
|
||||
}
|
||||
|
||||
if (querystring && typeof querystring === 'object') {
|
||||
for (let param in querystring) {
|
||||
if (param && querystring.hasOwnProperty(param) && querystring[param]) {
|
||||
url += param + '=' + querystring[param] + '&';
|
||||
}
|
||||
}
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
function getQuery(url) {
|
||||
var theRequest = [];
|
||||
if (url.indexOf("?") != -1) {
|
||||
var str = url.split('?')[1];
|
||||
var strs = str.split("&");
|
||||
for (var i = 0; i < strs.length; i++) {
|
||||
if (strs[i].split("=")[0] && unescape(strs[i].split("=")[1])) {
|
||||
theRequest[i] = {
|
||||
'name': strs[i].split("=")[0],
|
||||
'value': unescape(strs[i].split("=")[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return theRequest;
|
||||
}
|
||||
/*
|
||||
* 获取链接某个参数
|
||||
* url 链接地址
|
||||
* name 参数名称
|
||||
*/
|
||||
function getUrlParam(url, name) {
|
||||
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
|
||||
var r = url.split('?')[1].match(reg); //匹配目标参数
|
||||
if (r != null) return unescape(r[2]);
|
||||
return null; //返回参数值
|
||||
}
|
||||
/**
|
||||
* 获取签名 将链接地址的所有参数按字母排序后拼接加上token进行md5
|
||||
* url 链接地址
|
||||
* date 参数{参数名1 : 值1, 参数名2 : 值2} *
|
||||
* token 签名token 非必须
|
||||
*/
|
||||
function getSign(url, data, token) {
|
||||
var _ = require('underscore.js');
|
||||
var md5 = require('md5.js');
|
||||
var querystring = '';
|
||||
var sign = getUrlParam(url, 'sign');
|
||||
if (sign || (data && data.sign)) {
|
||||
return false;
|
||||
} else {
|
||||
if (url) {
|
||||
querystring = getQuery(url);
|
||||
}
|
||||
if (data) {
|
||||
var theRequest = [];
|
||||
for (let param in data) {
|
||||
if (param && data[param]) {
|
||||
theRequest = theRequest.concat({
|
||||
'name': param,
|
||||
'value': data[param]
|
||||
})
|
||||
}
|
||||
}
|
||||
querystring = querystring.concat(theRequest);
|
||||
}
|
||||
//排序
|
||||
querystring = _.sortBy(querystring, 'name');
|
||||
//去重
|
||||
querystring = _.uniq(querystring, true, 'name');
|
||||
var urlData = '';
|
||||
for (let i = 0; i < querystring.length; i++) {
|
||||
if (querystring[i] && querystring[i].name && querystring[i].value) {
|
||||
urlData += querystring[i].name + '=' + querystring[i].value;
|
||||
if (i < (querystring.length - 1)) {
|
||||
urlData += '&';
|
||||
}
|
||||
}
|
||||
}
|
||||
token = token ? token : app.siteInfo.token;
|
||||
sign = md5(urlData + token);
|
||||
return sign;
|
||||
}
|
||||
}
|
||||
util.getSign = function(url, data, token) {
|
||||
return getSign(url, data, token);
|
||||
};
|
||||
/**
|
||||
二次封装微信wx.request函数、增加交互体全、配置缓存、以及配合微擎格式化返回数据
|
||||
@params option 弹出参数表,
|
||||
{
|
||||
url : 同微信,
|
||||
data : 同微信,
|
||||
header : 同微信,
|
||||
method : 同微信,
|
||||
success : 同微信,
|
||||
fail : 同微信,
|
||||
complete : 同微信,
|
||||
cachetime : 缓存周期,在此周期内不重复请求http,默认不缓存
|
||||
}
|
||||
*/
|
||||
util.request = function(option) {
|
||||
var _ = require('underscore.js');
|
||||
var md5 = require('md5.js');
|
||||
var option = option ? option : {};
|
||||
option.cachetime = option.cachetime ? option.cachetime : 0;
|
||||
option.showLoading = typeof option.showLoading != 'undefined' ? option.showLoading : true;
|
||||
|
||||
var sessionid = wx.getStorageSync('userInfo').sessionid;
|
||||
var url = option.url;
|
||||
if (url.indexOf('http://') == -1 && url.indexOf('https://') == -1) {
|
||||
url = util.url(url);
|
||||
}
|
||||
var state = getUrlParam(url, 'state');
|
||||
if (!state && !(option.data && option.data.state) && sessionid) {
|
||||
url = url + '&state=we7sid-' + sessionid
|
||||
}
|
||||
if (!option.data || !option.data.m) {
|
||||
var nowPage = getCurrentPages();
|
||||
if (nowPage.length) {
|
||||
nowPage = nowPage[getCurrentPages().length - 1];
|
||||
if (nowPage && nowPage.__route__) {
|
||||
url = url + '&m=' + nowPage.__route__.split('/')[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var sign = getSign(url, option.data);
|
||||
if (sign) {
|
||||
url = url + "&sign=" + sign;
|
||||
}
|
||||
if (!url) {
|
||||
return false;
|
||||
}
|
||||
//wx.showNavigationBarLoading();
|
||||
if (option.showLoading) {
|
||||
//util.showLoading();
|
||||
}
|
||||
if (option.cachetime) {
|
||||
var cachekey = md5(url);
|
||||
var cachedata = wx.getStorageSync(cachekey);
|
||||
var timestamp = Date.parse(new Date());
|
||||
|
||||
if (cachedata && cachedata.data) {
|
||||
if (cachedata.expire > timestamp) {
|
||||
if (option.complete && typeof option.complete == 'function') {
|
||||
option.complete(cachedata);
|
||||
}
|
||||
if (option.success && typeof option.success == 'function') {
|
||||
option.success(cachedata);
|
||||
}
|
||||
console.log('cache:' + url);
|
||||
// wx.hideLoading();
|
||||
//wx.hideNavigationBarLoading();
|
||||
return true;
|
||||
} else {
|
||||
wx.removeStorageSync(cachekey)
|
||||
}
|
||||
}
|
||||
}
|
||||
wx.request({
|
||||
'url': url,
|
||||
'data': option.data ? option.data : {},
|
||||
'header': option.header ? option.header : {},
|
||||
'method': option.method ? option.method : 'GET',
|
||||
'header': {
|
||||
'content-type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
'success': function(response) {
|
||||
//wx.hideNavigationBarLoading();
|
||||
//wx.hideLoading();
|
||||
if (response.data.errno) {
|
||||
if (response.data.errno == '41009') {
|
||||
wx.setStorageSync('userInfo', '');
|
||||
util.getUserInfo(function() {
|
||||
util.request(option)
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
if (option.fail && typeof option.fail == 'function') {
|
||||
option.fail(response);
|
||||
} else {
|
||||
if (response.data.message) {
|
||||
if (response.data.data != null && response.data.data.redirect) {
|
||||
var redirect = response.data.data.redirect;
|
||||
} else {
|
||||
var redirect = '';
|
||||
}
|
||||
app.util.message(response.data.message, redirect, 'error');
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (option.success && typeof option.success == 'function') {
|
||||
option.success(response);
|
||||
}
|
||||
//写入缓存,减少HTTP请求,并且如果网络异常可以读取缓存数据
|
||||
if (option.cachetime) {
|
||||
var cachedata = {
|
||||
'data': response.data,
|
||||
'expire': timestamp + option.cachetime * 1000
|
||||
};
|
||||
wx.setStorageSync(cachekey, cachedata);
|
||||
}
|
||||
}
|
||||
},
|
||||
'fail': function(response) {
|
||||
wx.hideNavigationBarLoading();
|
||||
wx.hideLoading();
|
||||
|
||||
//如果请求失败,尝试从缓存中读取数据
|
||||
var md5 = require('md5.js');
|
||||
var cachekey = md5(url);
|
||||
var cachedata = wx.getStorageSync(cachekey);
|
||||
if (cachedata && cachedata.data) {
|
||||
if (option.success && typeof option.success == 'function') {
|
||||
option.success(cachedata);
|
||||
}
|
||||
console.log('failreadcache:' + url);
|
||||
return true;
|
||||
} else {
|
||||
if (option.fail && typeof option.fail == 'function') {
|
||||
option.fail(response);
|
||||
}
|
||||
}
|
||||
},
|
||||
'complete': function(response) {
|
||||
// wx.hideNavigationBarLoading();
|
||||
// wx.hideLoading();
|
||||
if (option.complete && typeof option.complete == 'function') {
|
||||
option.complete(response);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
/*
|
||||
* 获取用户信息
|
||||
*/
|
||||
util.getUserInfo = function(cb) {
|
||||
var login = function() {
|
||||
console.log('start login');
|
||||
var userInfo = {
|
||||
'sessionid': '',
|
||||
'wxInfo': '',
|
||||
'memberInfo': '',
|
||||
};
|
||||
wx.login({
|
||||
success: function(res) {
|
||||
util.request({
|
||||
url: 'auth/session/openid',
|
||||
data: {
|
||||
code: res.code
|
||||
},
|
||||
cachetime: 0,
|
||||
success: function(session) {
|
||||
if (!session.data.errno) {
|
||||
userInfo.sessionid = session.data.data.sessionid
|
||||
wx.setStorageSync('userInfo', userInfo);
|
||||
wx.getUserInfo({
|
||||
success: function(wxInfo) {
|
||||
userInfo.wxInfo = wxInfo.userInfo
|
||||
wx.setStorageSync('userInfo', userInfo);
|
||||
util.request({
|
||||
url: 'auth/session/userinfo',
|
||||
data: {
|
||||
signature: wxInfo.signature,
|
||||
rawData: wxInfo.rawData,
|
||||
iv: wxInfo.iv,
|
||||
encryptedData: wxInfo.encryptedData
|
||||
},
|
||||
method: 'POST',
|
||||
header: {
|
||||
'content-type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
cachetime: 0,
|
||||
success: function(res) {
|
||||
if (!res.data.errno) {
|
||||
userInfo.memberInfo = res.data.data;
|
||||
wx.setStorageSync('userInfo', userInfo);
|
||||
}
|
||||
typeof cb == "function" && cb(userInfo);
|
||||
}
|
||||
});
|
||||
},
|
||||
fail: function() {
|
||||
typeof cb == "function" && cb(userInfo);
|
||||
},
|
||||
complete: function() {}
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
fail: function() {
|
||||
wx.showModal({
|
||||
title: '获取信息失败',
|
||||
content: '请允许授权以便为您提供给服务',
|
||||
success: function(res) {
|
||||
if (res.confirm) {
|
||||
util.getUserInfo();
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var app = wx.getStorageSync('userInfo');
|
||||
if (app.sessionid) {
|
||||
wx.checkSession({
|
||||
success: function() {
|
||||
typeof cb == "function" && cb(app);
|
||||
},
|
||||
fail: function() {
|
||||
app.sessionid = '';
|
||||
console.log('relogin');
|
||||
wx.removeStorageSync('userInfo');
|
||||
login();
|
||||
}
|
||||
})
|
||||
} else {
|
||||
//调用登录接口
|
||||
login();
|
||||
}
|
||||
}
|
||||
|
||||
util.navigateBack = function(obj) {
|
||||
let delta = obj.delta ? obj.delta : 1;
|
||||
if (obj.data) {
|
||||
let pages = getCurrentPages()
|
||||
let curPage = pages[pages.length - (delta + 1)];
|
||||
if (curPage.pageForResult) {
|
||||
curPage.pageForResult(obj.data);
|
||||
} else {
|
||||
curPage.setData(obj.data);
|
||||
}
|
||||
}
|
||||
wx.navigateBack({
|
||||
delta: delta, // 回退前 delta(默认为1) 页面
|
||||
success: function(res) {
|
||||
// success
|
||||
typeof obj.success == "function" && obj.success(res);
|
||||
},
|
||||
fail: function(err) {
|
||||
// fail
|
||||
typeof obj.fail == "function" && obj.fail(err);
|
||||
},
|
||||
complete: function() {
|
||||
// complete
|
||||
typeof obj.complete == "function" && obj.complete();
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
util.footer = function($this) {
|
||||
let that = $this;
|
||||
let tabBar = app.tabBar;
|
||||
for (let i in tabBar['list']) {
|
||||
tabBar['list'][i]['pageUrl'] = tabBar['list'][i]['pagePath'].replace(/(\?|#)[^"]*/g, '')
|
||||
}
|
||||
that.setData({
|
||||
tabBar: tabBar,
|
||||
'tabBar.thisurl': that.__route__
|
||||
})
|
||||
};
|
||||
/*
|
||||
* 提示信息
|
||||
* type 为 success, error 当为 success, 时,为toast方式,否则为模态框的方式
|
||||
* redirect 为提示后的跳转地址, 跳转的时候可以加上 协议名称
|
||||
* navigate:/we7/pages/detail/detail 以 navigateTo 的方法跳转,
|
||||
* redirect:/we7/pages/detail/detail 以 redirectTo 的方式跳转,默认为 redirect
|
||||
*/
|
||||
util.message = function (title, redirect, type, confirmText="确定") {
|
||||
if (!title) {
|
||||
return true;
|
||||
}
|
||||
if (typeof title == 'object') {
|
||||
redirect = title.redirect;
|
||||
type = title.type;
|
||||
title = title.title;
|
||||
}
|
||||
if (redirect) {
|
||||
var redirectType = redirect.substring(0, 9),
|
||||
url = '',
|
||||
redirectFunction = '';
|
||||
if (redirectType == 'navigate:') {
|
||||
redirectFunction = 'navigateTo';
|
||||
url = redirect.substring(9);
|
||||
} else if (redirectType == 'redirect:') {
|
||||
redirectFunction = 'redirectTo';
|
||||
url = redirect.substring(9);
|
||||
} else if (redirectType == 'switchTo:') {
|
||||
redirectFunction = 'switchTab';
|
||||
url = redirect.substring(9);
|
||||
} else {
|
||||
url = redirect;
|
||||
redirectFunction = 'redirectTo';
|
||||
}
|
||||
}
|
||||
if (!type) {
|
||||
type = 'success';
|
||||
}
|
||||
|
||||
if (type == 'success') {
|
||||
wx.showToast({
|
||||
title: title,
|
||||
icon: 'success',
|
||||
duration: 2000,
|
||||
mask: url ? true : false,
|
||||
complete: function() {
|
||||
if (url) {
|
||||
setTimeout(function() {
|
||||
wx[redirectFunction]({
|
||||
url: url,
|
||||
});
|
||||
}, 1800);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
} else if (type == 'error') {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: title,
|
||||
showCancel: false,
|
||||
confirmColor: '#ff5041',
|
||||
confirmText,
|
||||
complete: function() {
|
||||
if (url) {
|
||||
wx[redirectFunction]({
|
||||
url: url,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
util.navTo = function (redirect){
|
||||
if (redirect) {
|
||||
var redirectType = redirect.substring(0, 9),
|
||||
url = '',
|
||||
redirectFunction = '';
|
||||
if (redirectType == 'navigate:') {
|
||||
redirectFunction = 'navigateTo';
|
||||
url = redirect.substring(9);
|
||||
} else if (redirectType == 'redirect:') {
|
||||
redirectFunction = 'redirectTo';
|
||||
url = redirect.substring(9);
|
||||
} else if (redirectType == 'switchTo:') {
|
||||
redirectFunction = 'switchTab';
|
||||
url = redirect.substring(9);
|
||||
} else {
|
||||
url = redirect;
|
||||
redirectFunction = 'redirectTo';
|
||||
}
|
||||
url && wx[redirectFunction]({ url });
|
||||
}
|
||||
}
|
||||
|
||||
util.user = util.getUserInfo;
|
||||
|
||||
//封装微信等待提示,防止ajax过多时,show多次
|
||||
util.showLoading = function() {
|
||||
var isShowLoading = wx.getStorageSync('isShowLoading');
|
||||
if (isShowLoading) {
|
||||
wx.hideLoading();
|
||||
wx.setStorageSync('isShowLoading', false);
|
||||
}
|
||||
|
||||
wx.showLoading({
|
||||
title: '加载中',
|
||||
complete: function() {
|
||||
wx.setStorageSync('isShowLoading', true);
|
||||
},
|
||||
fail: function() {
|
||||
wx.setStorageSync('isShowLoading', false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
util.showImage = function(event) {
|
||||
var url = event ? event.currentTarget.dataset.preview : '';
|
||||
if (!url) {
|
||||
return false;
|
||||
}
|
||||
wx.previewImage({
|
||||
urls: [url]
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换内容中的emoji表情为 unicode 码点,在Php中使用utf8_bytes来转换输出
|
||||
*/
|
||||
util.parseContent = function(string) {
|
||||
if (!string) {
|
||||
return string;
|
||||
}
|
||||
|
||||
var ranges = [
|
||||
'\ud83c[\udf00-\udfff]', // U+1F300 to U+1F3FF
|
||||
'\ud83d[\udc00-\ude4f]', // U+1F400 to U+1F64F
|
||||
'\ud83d[\ude80-\udeff]' // U+1F680 to U+1F6FF
|
||||
];
|
||||
var emoji = string.match(
|
||||
new RegExp(ranges.join('|'), 'g'));
|
||||
|
||||
if (emoji) {
|
||||
for (var i in emoji) {
|
||||
string = string.replace(emoji[i], '[U+' + emoji[i].codePointAt(0).toString(16).toUpperCase() + ']');
|
||||
}
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
util.date = function() {
|
||||
/**
|
||||
* 判断闰年
|
||||
* @param date Date日期对象
|
||||
* @return boolean true 或false
|
||||
*/
|
||||
this.isLeapYear = function(date) {
|
||||
return (0 == date.getYear() % 4 && ((date.getYear() % 100 != 0) || (date.getYear() % 400 == 0)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期对象转换为指定格式的字符串
|
||||
* @param f 日期格式,格式定义如下 yyyy-MM-dd HH:mm:ss
|
||||
* @param date Date日期对象, 如果缺省,则为当前时间
|
||||
*
|
||||
* YYYY/yyyy/YY/yy 表示年份
|
||||
* MM/M 月份
|
||||
* W/w 星期
|
||||
* dd/DD/d/D 日期
|
||||
* hh/HH/h/H 时间
|
||||
* mm/m 分钟
|
||||
* ss/SS/s/S 秒
|
||||
* @return string 指定格式的时间字符串
|
||||
*/
|
||||
this.dateToStr = function(formatStr, date) {
|
||||
formatStr = arguments[0] || "yyyy-MM-dd HH:mm:ss";
|
||||
date = arguments[1] || new Date();
|
||||
var str = formatStr;
|
||||
var Week = ['日', '一', '二', '三', '四', '五', '六'];
|
||||
str = str.replace(/yyyy|YYYY/, date.getFullYear());
|
||||
str = str.replace(/yy|YY/, (date.getYear() % 100) > 9 ? (date.getYear() % 100).toString() : '0' + (date.getYear() % 100));
|
||||
str = str.replace(/MM/, date.getMonth() > 9 ? (date.getMonth() + 1) : '0' + (date.getMonth() + 1));
|
||||
str = str.replace(/M/g, date.getMonth());
|
||||
str = str.replace(/w|W/g, Week[date.getDay()]);
|
||||
|
||||
str = str.replace(/dd|DD/, date.getDate() > 9 ? date.getDate().toString() : '0' + date.getDate());
|
||||
str = str.replace(/d|D/g, date.getDate());
|
||||
|
||||
str = str.replace(/hh|HH/, date.getHours() > 9 ? date.getHours().toString() : '0' + date.getHours());
|
||||
str = str.replace(/h|H/g, date.getHours());
|
||||
str = str.replace(/mm/, date.getMinutes() > 9 ? date.getMinutes().toString() : '0' + date.getMinutes());
|
||||
str = str.replace(/m/g, date.getMinutes());
|
||||
|
||||
str = str.replace(/ss|SS/, date.getSeconds() > 9 ? date.getSeconds().toString() : '0' + date.getSeconds());
|
||||
str = str.replace(/s|S/g, date.getSeconds());
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 日期计算
|
||||
* @param strInterval string 可选值 y 年 m月 d日 w星期 ww周 h时 n分 s秒
|
||||
* @param num int
|
||||
* @param date Date 日期对象
|
||||
* @return Date 返回日期对象
|
||||
*/
|
||||
this.dateAdd = function(strInterval, num, date) {
|
||||
date = arguments[2] || new Date();
|
||||
switch (strInterval) {
|
||||
case 's':
|
||||
return new Date(date.getTime() + (1000 * num));
|
||||
case 'n':
|
||||
return new Date(date.getTime() + (60000 * num));
|
||||
case 'h':
|
||||
return new Date(date.getTime() + (3600000 * num));
|
||||
case 'd':
|
||||
return new Date(date.getTime() + (86400000 * num));
|
||||
case 'w':
|
||||
return new Date(date.getTime() + ((86400000 * 7) * num));
|
||||
case 'm':
|
||||
return new Date(date.getFullYear(), (date.getMonth()) + num, date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds());
|
||||
case 'y':
|
||||
return new Date((date.getFullYear() + num), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 比较日期差 dtEnd 格式为日期型或者有效日期格式字符串
|
||||
* @param strInterval string 可选值 y 年 m月 d日 w星期 ww周 h时 n分 s秒
|
||||
* @param dtStart Date 可选值 y 年 m月 d日 w星期 ww周 h时 n分 s秒
|
||||
* @param dtEnd Date 可选值 y 年 m月 d日 w星期 ww周 h时 n分 s秒
|
||||
*/
|
||||
this.dateDiff = function(strInterval, dtStart, dtEnd) {
|
||||
switch (strInterval) {
|
||||
case 's':
|
||||
return parseInt((dtEnd - dtStart) / 1000);
|
||||
case 'n':
|
||||
return parseInt((dtEnd - dtStart) / 60000);
|
||||
case 'h':
|
||||
return parseInt((dtEnd - dtStart) / 3600000);
|
||||
case 'd':
|
||||
return parseInt((dtEnd - dtStart) / 86400000);
|
||||
case 'w':
|
||||
return parseInt((dtEnd - dtStart) / (86400000 * 7));
|
||||
case 'm':
|
||||
return (dtEnd.getMonth() + 1) + ((dtEnd.getFullYear() - dtStart.getFullYear()) * 12) - (dtStart.getMonth() + 1);
|
||||
case 'y':
|
||||
return dtEnd.getFullYear() - dtStart.getFullYear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串转换为日期对象 // eval 不可用
|
||||
* @param date Date 格式为yyyy-MM-dd HH:mm:ss,必须按年月日时分秒的顺序,中间分隔符不限制
|
||||
*/
|
||||
this.strToDate = function(dateStr) {
|
||||
var data = dateStr;
|
||||
var reCat = /(\d{1,4})/gm;
|
||||
var t = data.match(reCat);
|
||||
t[1] = t[1] - 1;
|
||||
eval('var d = new Date(' + t.join(',') + ');');
|
||||
return d;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把指定格式的字符串转换为日期对象yyyy-MM-dd HH:mm:ss
|
||||
*
|
||||
*/
|
||||
this.strFormatToDate = function(formatStr, dateStr) {
|
||||
var year = 0;
|
||||
var start = -1;
|
||||
var len = dateStr.length;
|
||||
if ((start = formatStr.indexOf('yyyy')) > -1 && start < len) {
|
||||
year = dateStr.substr(start, 4);
|
||||
}
|
||||
var month = 0;
|
||||
if ((start = formatStr.indexOf('MM')) > -1 && start < len) {
|
||||
month = parseInt(dateStr.substr(start, 2)) - 1;
|
||||
}
|
||||
var day = 0;
|
||||
if ((start = formatStr.indexOf('dd')) > -1 && start < len) {
|
||||
day = parseInt(dateStr.substr(start, 2));
|
||||
}
|
||||
var hour = 0;
|
||||
if (((start = formatStr.indexOf('HH')) > -1 || (start = formatStr.indexOf('hh')) > 1) && start < len) {
|
||||
hour = parseInt(dateStr.substr(start, 2));
|
||||
}
|
||||
var minute = 0;
|
||||
if ((start = formatStr.indexOf('mm')) > -1 && start < len) {
|
||||
minute = dateStr.substr(start, 2);
|
||||
}
|
||||
var second = 0;
|
||||
if ((start = formatStr.indexOf('ss')) > -1 && start < len) {
|
||||
second = dateStr.substr(start, 2);
|
||||
}
|
||||
return new Date(year, month, day, hour, minute, second);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 日期对象转换为毫秒数
|
||||
*/
|
||||
this.dateToLong = function(date) {
|
||||
return date.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 毫秒转换为日期对象
|
||||
* @param dateVal number 日期的毫秒数
|
||||
*/
|
||||
this.longToDate = function(dateVal) {
|
||||
return new Date(dateVal);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字符串是否为日期格式
|
||||
* @param str string 字符串
|
||||
* @param formatStr string 日期格式, 如下 yyyy-MM-dd
|
||||
*/
|
||||
this.isDate = function(str, formatStr) {
|
||||
if (formatStr == null) {
|
||||
formatStr = "yyyyMMdd";
|
||||
}
|
||||
var yIndex = formatStr.indexOf("yyyy");
|
||||
if (yIndex == -1) {
|
||||
return false;
|
||||
}
|
||||
var year = str.substring(yIndex, yIndex + 4);
|
||||
var mIndex = formatStr.indexOf("MM");
|
||||
if (mIndex == -1) {
|
||||
return false;
|
||||
}
|
||||
var month = str.substring(mIndex, mIndex + 2);
|
||||
var dIndex = formatStr.indexOf("dd");
|
||||
if (dIndex == -1) {
|
||||
return false;
|
||||
}
|
||||
var day = str.substring(dIndex, dIndex + 2);
|
||||
if (!isNumber(year) || year > "2100" || year < "1900") {
|
||||
return false;
|
||||
}
|
||||
if (!isNumber(month) || month > "12" || month < "01") {
|
||||
return false;
|
||||
}
|
||||
if (day > getMaxDay(year, month) || day < "01") {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
this.getMaxDay = function(year, month) {
|
||||
if (month == 4 || month == 6 || month == 9 || month == 11)
|
||||
return "30";
|
||||
if (month == 2)
|
||||
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
|
||||
return "29";
|
||||
else
|
||||
return "28";
|
||||
return "31";
|
||||
}
|
||||
/**
|
||||
* 变量是否为数字
|
||||
*/
|
||||
this.isNumber = function(str) {
|
||||
var regExp = /^\d+$/g;
|
||||
return regExp.test(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 把日期分割成数组 [年、月、日、时、分、秒]
|
||||
*/
|
||||
this.toArray = function(myDate) {
|
||||
myDate = arguments[0] || new Date();
|
||||
var myArray = Array();
|
||||
myArray[0] = myDate.getFullYear();
|
||||
myArray[1] = myDate.getMonth();
|
||||
myArray[2] = myDate.getDate();
|
||||
myArray[3] = myDate.getHours();
|
||||
myArray[4] = myDate.getMinutes();
|
||||
myArray[5] = myDate.getSeconds();
|
||||
return myArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得日期数据信息
|
||||
* 参数 interval 表示数据类型
|
||||
* y 年 M月 d日 w星期 ww周 h时 n分 s秒
|
||||
*/
|
||||
this.datePart = function(interval, myDate) {
|
||||
myDate = arguments[1] || new Date();
|
||||
var partStr = '';
|
||||
var Week = ['日', '一', '二', '三', '四', '五', '六'];
|
||||
switch (interval) {
|
||||
case 'y':
|
||||
partStr = myDate.getFullYear();
|
||||
break;
|
||||
case 'M':
|
||||
partStr = myDate.getMonth() + 1;
|
||||
break;
|
||||
case 'd':
|
||||
partStr = myDate.getDate();
|
||||
break;
|
||||
case 'w':
|
||||
partStr = Week[myDate.getDay()];
|
||||
break;
|
||||
case 'ww':
|
||||
partStr = myDate.WeekNumOfYear();
|
||||
break;
|
||||
case 'h':
|
||||
partStr = myDate.getHours();
|
||||
break;
|
||||
case 'm':
|
||||
partStr = myDate.getMinutes();
|
||||
break;
|
||||
case 's':
|
||||
partStr = myDate.getSeconds();
|
||||
break;
|
||||
}
|
||||
return partStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 取得当前日期所在月的最大天数
|
||||
*/
|
||||
this.maxDayOfDate = function(date) {
|
||||
date = arguments[0] || new Date();
|
||||
date.setDate(1);
|
||||
date.setMonth(date.getMonth() + 1);
|
||||
var time = date.getTime() - 24 * 60 * 60 * 1000;
|
||||
var newDate = new Date(time);
|
||||
return newDate.getDate();
|
||||
}
|
||||
};
|
||||
|
||||
util.getLightColor = function(color, level) {
|
||||
color = color ? color.toUpperCase() : color;
|
||||
var r = /^\#?[0-9A-F]{6}$/;
|
||||
if (!r.test(color)) return color;
|
||||
color = color.replace("#", "");
|
||||
var hxs = color.match(/../g);
|
||||
for (var i = 0; i < 3; i++) {
|
||||
var col = parseInt(hxs[i], 16);
|
||||
hxs[i] = Math.floor((255 - col) * level + col);
|
||||
}
|
||||
return `rgb(${hxs[0]}, ${hxs[1]}, ${hxs[2]})`;
|
||||
}
|
||||
|
||||
util.ProReq = function(controller, params) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
util.request({
|
||||
url: 'entry/wxapp/index',
|
||||
data: {
|
||||
controller,
|
||||
...params
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function (res) {
|
||||
wx.hideLoading();
|
||||
if (res.data.code == 0) {
|
||||
resolve(res.data)
|
||||
} else {
|
||||
reject(res.data)
|
||||
}
|
||||
},
|
||||
fail: err=>{
|
||||
console.log(err)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = util;
|
|
@ -0,0 +1,57 @@
|
|||
{
|
||||
"description": "项目配置文件,详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
|
||||
"packOptions": {
|
||||
"ignore": [],
|
||||
"include": []
|
||||
},
|
||||
"setting": {
|
||||
"urlCheck": true,
|
||||
"es6": false,
|
||||
"enhance": true,
|
||||
"postcss": true,
|
||||
"preloadBackgroundData": false,
|
||||
"minified": true,
|
||||
"newFeature": false,
|
||||
"coverView": true,
|
||||
"nodeModules": true,
|
||||
"autoAudits": false,
|
||||
"showShadowRootInWxmlPanel": true,
|
||||
"scopeDataCheck": false,
|
||||
"uglifyFileName": true,
|
||||
"checkInvalidKey": true,
|
||||
"checkSiteMap": true,
|
||||
"uploadWithSourceMap": true,
|
||||
"compileHotReLoad": false,
|
||||
"lazyloadPlaceholderEnable": false,
|
||||
"useMultiFrameRuntime": true,
|
||||
"useApiHook": true,
|
||||
"useApiHostProcess": true,
|
||||
"babelSetting": {
|
||||
"ignore": [],
|
||||
"disablePlugins": [],
|
||||
"outputPath": ""
|
||||
},
|
||||
"enableEngineNative": false,
|
||||
"useIsolateContext": false,
|
||||
"userConfirmedBundleSwitch": false,
|
||||
"packNpmManually": false,
|
||||
"packNpmRelationList": [],
|
||||
"minifyWXSS": true,
|
||||
"disableUseStrict": false,
|
||||
"minifyWXML": true,
|
||||
"showES6CompileOption": false,
|
||||
"useCompilerPlugins": false,
|
||||
"useStaticServer": true,
|
||||
"ignoreUploadUnusedFiles": false,
|
||||
"condition": false
|
||||
},
|
||||
"compileType": "miniprogram",
|
||||
"libVersion": "2.30.1",
|
||||
"appid": "wx95e000d520e78bdc",
|
||||
"projectname": "EP-WeChatApp-5.2.1",
|
||||
"condition": {},
|
||||
"editorSetting": {
|
||||
"tabIndent": "insertSpaces",
|
||||
"tabSize": 4
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
|
||||
"libVersion": "2.17.0",
|
||||
"setting": {
|
||||
"autoAudits": true,
|
||||
"compileHotReLoad": true,
|
||||
"urlCheck": false
|
||||
},
|
||||
"condition": {
|
||||
"miniprogram": {
|
||||
"list": [
|
||||
{
|
||||
"name": "",
|
||||
"pathName": "eaterplanet_ecommerce/moduleA/groupCenter/pendingDeliveryOrders",
|
||||
"query": "memberId=49",
|
||||
"launchMode": "default",
|
||||
"scene": null
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"pathName": "eaterplanet_ecommerce/pages/order/shopCart",
|
||||
"query": "",
|
||||
"launchMode": "default",
|
||||
"scene": null
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"pathName": "eaterplanet_ecommerce/pages/user/me",
|
||||
"query": "",
|
||||
"launchMode": "default",
|
||||
"scene": null
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"projectname": "EP-WeChatApp-5.2.1"
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
var siteinfo = { "siteroot": "https://shop.ofme.cn/wxapp.php"}
|
||||
module.exports = siteinfo
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
|
||||
"rules": [{
|
||||
"action": "allow",
|
||||
"page": "*"
|
||||
}]
|
||||
}
|
Loading…
Reference in New Issue