初始化
60
pages/addFunction/addFunction.js
Normal file
@@ -0,0 +1,60 @@
|
||||
// pages/addFunction/addFunction.js
|
||||
|
||||
const code = `// 云函数入口函数
|
||||
exports.main = (event, context) => {
|
||||
console.log(event)
|
||||
console.log(context)
|
||||
return {
|
||||
sum: event.a + event.b
|
||||
}
|
||||
}`
|
||||
|
||||
Page({
|
||||
|
||||
data: {
|
||||
result: '',
|
||||
canIUseClipboard: wx.canIUse('setClipboardData'),
|
||||
},
|
||||
|
||||
onLoad: function (options) {
|
||||
|
||||
},
|
||||
|
||||
copyCode: function() {
|
||||
wx.setClipboardData({
|
||||
data: code,
|
||||
success: function () {
|
||||
wx.showToast({
|
||||
title: '复制成功',
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
testFunction() {
|
||||
wx.cloud.callFunction({
|
||||
name: 'sum',
|
||||
data: {
|
||||
a: 1,
|
||||
b: 2
|
||||
},
|
||||
success: res => {
|
||||
wx.showToast({
|
||||
title: '调用成功',
|
||||
})
|
||||
this.setData({
|
||||
result: JSON.stringify(res.result)
|
||||
})
|
||||
},
|
||||
fail: err => {
|
||||
wx.showToast({
|
||||
icon: 'none',
|
||||
title: '调用失败',
|
||||
})
|
||||
console.error('[云函数] [sum] 调用失败:', err)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
})
|
||||
|
||||
4
pages/addFunction/addFunction.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"navigationBarTitleText": "云函数指引",
|
||||
"usingComponents": {}
|
||||
}
|
||||
29
pages/addFunction/addFunction.wxml
Normal file
@@ -0,0 +1,29 @@
|
||||
<!--pages/addFunction/addFunction.wxml-->
|
||||
<view class="container">
|
||||
|
||||
<view class="list">
|
||||
<view class="list-item" bindtap="testFunction">
|
||||
<text>测试云函数</text>
|
||||
</view>
|
||||
<view class="list-item">
|
||||
<text class="request-text">期望输出:{"sum":3}</text>
|
||||
</view>
|
||||
<view class="list-item" wx:if="{{result}}">
|
||||
<text class="request-text">调用结果:{{result}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="guide">
|
||||
<text class="headline">新增云函数</text>
|
||||
<text class="p">1. 在云函数根目录 cloudfunctions 上右键选择新建云函数,命名为 sum</text>
|
||||
<text class="p">2. 在创建的 cloudfunctions/sum/index.js 文件中添加如下代码</text>
|
||||
<image class="image1" src="../../images/code-func-sum.png" mode="aspectFit"></image>
|
||||
<button class="copyBtn" wx:if="{{canIUseClipboard}}" bindtap="copyCode">复制代码</button>
|
||||
<text class="p">3. 在 cloudfunctions/sum 目录上右键上传并部署</text>
|
||||
<text class="p">4. 点击测试云函数测试</text>
|
||||
<text class="p">5. 打开云开发云函数管理页,选择 sum 云函数</text>
|
||||
<text class="p">6. 查看 sum 的调用日志</text>
|
||||
<text class="p">进阶:可在云函数中使用 wx-server-sdk 操作数据库,文件存储和调用其他云函数,详见文档</text>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
3
pages/addFunction/addFunction.wxss
Normal file
@@ -0,0 +1,3 @@
|
||||
/* pages/addFunction/addFunction.wxss */
|
||||
|
||||
@import "../../style/guide.wxss";
|
||||
66
pages/agreement/index.js
Normal file
@@ -0,0 +1,66 @@
|
||||
// pages/agreement/index.js
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function () {
|
||||
|
||||
}
|
||||
})
|
||||
7
pages/agreement/index.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"navigationBarBackgroundColor": "#f48218",
|
||||
"navigationBarTextStyle": "white",
|
||||
"navigationBarTitleText": "电子油卡使用须知",
|
||||
"backgroundColor": "#eeeeee",
|
||||
"backgroundTextStyle": "light"
|
||||
}
|
||||
16
pages/agreement/index.wxml
Normal file
@@ -0,0 +1,16 @@
|
||||
<view class="title">电子油卡使用须知</view>
|
||||
|
||||
<view class="section">
|
||||
1、“运费油卡”仅用于展示本平台(无车承运人)向实际承运人(以下简称“您”或“司机”)提供油品物资情况的虚拟记录,并不涉及发行任何电子卡、虚拟卡或实体卡等,不涉及开立任何类型的账户,不涉及进行任何类型的销售,不涉及任何支付、充值、消费等资金结算。
|
||||
</view>
|
||||
|
||||
<view class="section">2、“当前余额”表示本平台作为无车承运人分配给司机的、可用的油费额度,仅作为向司机展示可领物资(油品/天然气)信息的一个记录,并不对应任何财产,不支持退款和提现。</view>
|
||||
|
||||
<view class="section">3、您可基于“运费油卡”的记录,选择与本平台合作的加油站/加气站(具体以本平台上显示的加油站/加气站为准,该等加油站/加气站仅为本平台代为交付物资,而非对您销售)领取油品/天然气。在您领取油品/天然气后,您的可领物资(油品/天然气)的额度将相应减少,即您的“当前余额”将相应减少。</view>
|
||||
|
||||
<view class="section">4、您在使用“运费油卡”领取油品/天然气时,所使用的二维码仅作为识别您的身份的便利设置,并非付款凭证。</view>
|
||||
|
||||
<view class="section">5、您在使用“运费油卡”过程中,请您务必审慎阅读、充分理解特殊说明事项,包括但不限于本说明的全部内容以及页面提示的不支持开票/优惠券、不可用于其他消费、不支持退还和提现等内容;如果您不同意上述特殊说明的任何内容,或者无法准确理其含义,请不要进行确认及后续操作。若您进行确认或后续操作,即视为您知悉并同意上述特殊说明事项。</view>
|
||||
|
||||
<view class="section">6、平台声明:本平台上所有关于“运费油卡”、“当前余额”等名称/表述的使用,仅为用户阅读方便,不能作为法律关系实质解释的依据。本平台享有对该等名称/表述的最终解释权。</view>
|
||||
|
||||
14
pages/agreement/index.wxss
Normal file
@@ -0,0 +1,14 @@
|
||||
/* pages/agreement/index.wxss */
|
||||
|
||||
.title {
|
||||
font-size: 32rpx;
|
||||
text-align: center;
|
||||
line-height: 1.6em;
|
||||
}
|
||||
|
||||
.section {
|
||||
font-size: 30rpx;
|
||||
padding: 0.5em 1em;
|
||||
line-height: 1.4em;
|
||||
text-indent: 2em;
|
||||
}
|
||||
71
pages/agreement/login-agree.js
Normal file
@@ -0,0 +1,71 @@
|
||||
// pages/agreement/login-agree.js
|
||||
const app = getApp()
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
nvabarData: {
|
||||
showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
|
||||
title: '登录', //导航栏 中间的标题
|
||||
}, // 此页面 页面内容距最顶部的距离
|
||||
height: app.globalData.height * 2 + 20,
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function () {
|
||||
|
||||
}
|
||||
})
|
||||
10
pages/agreement/login-agree.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"navigationBarBackgroundColor": "#f48218",
|
||||
"navigationBarTextStyle": "white",
|
||||
"navigationBarTitleText": "卡运帮注册服务协议",
|
||||
"backgroundColor": "#eeeeee",
|
||||
"backgroundTextStyle": "light",
|
||||
"usingComponents": {
|
||||
"nav-bar": "/components/navbarTwo/index"
|
||||
}
|
||||
}
|
||||
86
pages/agreement/login-agree.wxml
Normal file
@@ -0,0 +1,86 @@
|
||||
|
||||
<nav-bar navbar-data='{{nvabarData}}'></nav-bar>
|
||||
<view class="title" style='margin-top: {{height}}px'>陆运帮客户端服务协议</view>
|
||||
|
||||
<view class="section">
|
||||
陕西陆运帮网络科技有限公司(以下简称“陆运帮”)所提供的一切服务的所有权、运营权、解释权、相关应用的知识产权均归陆运帮所有。注册会员时,请您认真阅读本协议,审阅后决定接受或不接受本协议。若您注册为会员,即表示您已充分阅读、理解并同意自己与陆运帮订立本协议,且您自愿受本协议条款的所有内容。本协议内容包括协议正文及陆运帮所有已经发布的各类规则。陆运帮已发布的所有规则为本协议不可分割的一部分,与本协议正文具有同等法律效力。
|
||||
</view>
|
||||
|
||||
<view class="section">陆运帮有权在必要时修改本协议,并通过在名为“陆运帮”的微信应用(以下简称“本应用”)上公告或名为“陆运帮”的微信公众号(以下简称“公众号”)上公告等合理方式告知会员。经修订的条款在本应用或公众号上公告后即自动生效。会员在享受各项服务时,应当及时查阅了解修改的内容,并自觉遵守本协议条款以及该单项服务的相关条款。会员如继续使用本协议条款涉及的服务,则视为对修改内容的同意,当发生有关争议时,以最新的协议条款为准;会员在不同意相关修改内容的情况下,必须停止使用本应用。除非得到陆运帮的书面授权,任何人将不得修改本协议。</view>
|
||||
|
||||
<view class="section">1、会员资格</view>
|
||||
|
||||
<view class="section">只有符合下列条件之一的自然人或法人才能申请成为本应用会员,可以使用本应用提供的服务:
|
||||
A、年满十八周岁,并具备相应的民事行为能力的自然人;
|
||||
B、根据中国法律、法规、行政规章成立并合法存在的机关、企事业单位、社团组织和其他组织。
|
||||
</view>
|
||||
|
||||
<view class="section">2、会员的账号、密码及其安全性</view>
|
||||
|
||||
<view class="section">
|
||||
您一旦注册成功成为会员,将得到一个账号和密码。会员可随时改变自己的密码,也可以结束旧的账号重开一个新账号。会员应对账号和密码的安全性负全部责任。陆运帮将不承担会员的账号和密码的一切安全及保密责任以及因会员的账号和密码的泄露所导致的一切损失。如果会员未保管好自己的帐号和密码而对会员、陆运帮或第三方造成损害,会员将负全部责任。会员同意若发现有任何非法使用自己的账号或者存在其他安全漏洞的情况,有义务立即通知陆运帮。
|
||||
</view>
|
||||
|
||||
<view class="section">3、会员权利与义务</view>
|
||||
|
||||
|
||||
<view>
|
||||
(1)会员有权根据本协议、本应用及公众号发布的相关规则,利用本应用发布货源、寻找货源、查询车辆信息,在本应用及相关产品发布信息,参加本应用的有关活动及有权享受本应用提供的其他有关资讯及信息服务。
|
||||
(2)会员应当向本应用提供真实准确完整的注册信息。同时,会员也应当在相关资料实际变更时及时更新有关注册资料。会员进一步同意其一旦将信息或资料在使用服务时提供,则表示同意放弃对此信息或资料所享有的隐私权、版权和相关财产权利。
|
||||
(3)会员不得以任何形式擅自转让或授权他人使用自己在本应用的会员账号。
|
||||
(4)会员有义务确保在本应用上发布的货源信息真实、准确无误。
|
||||
(5)会员有义务确保在规定的时间里完成订单的货运,若有变更必须提前征得货主同意。
|
||||
(6)会员承诺自己在使用本应用实施的所有行为遵守法律、法规、行政规章和本应用的相关规定以及各种社会公共利益或公共道德。如有违反导致任何法律后果的发生,会员将以自己的名义独立承担相应的法律责任。
|
||||
(7)会员不得使用以下方式登录应用或破坏其所提供的服务:
|
||||
A、以任何机器人软件、蜘蛛软件、爬虫软件、刷单软件或其它自动方式访问或登录本应用;
|
||||
B、通过任何方式对本公司 内部结构造成或可能造成不合理或不合比例的重大负荷的行为;
|
||||
C、通过任何方式干扰或试图干扰本应用的正常工作或本应用上进行的任何活动。
|
||||
(8)会员同意接收来自本应用的信息。
|
||||
</view>
|
||||
|
||||
<view class="section">4、违约责任</view>
|
||||
|
||||
<view>
|
||||
会员违反本协议规定的内容,给陆运帮造成损失的,应当承担违约责任,赔偿陆运帮因此所受的一切损失,包括但不限于本金损失、利息损失、因追索或诉讼而支出的诉讼费、合理的通讯费、交通费、住宿费、律师费等。
|
||||
</view>
|
||||
|
||||
<view class="section">5、免责条款</view>
|
||||
|
||||
<view class="section">
|
||||
(1)本应用作为一个信息交换平台,其信息是由各地方用户提供,各提供者对提供信息的内容承担全部责任。本应用要求信息提供者发布合法、真实、有效的信息,但本应用对此不承担任何责任。
|
||||
|
||||
(2)对任何经由本应用或从官网链接、下载或从任何与本应用有关信息服务所获得的信息、资料及广告,陆运帮不保证其内容的有效性、正确性或可靠性;对于会员通过本应用、公众号等获取的信息服务,如信息、广告或资讯,而发布、查询或取得的任何信息或资料,陆运帮概不负保证责任。会员因此所产生的风险应自行承担。本应用有权但无义务修改或更正在服务的信息内容或资料中存在的任何错误或疏漏。
|
||||
(3)本应用的信息、资料或广告是基于为会员服务的目的而存在的,陆运帮明确地拒绝对服务、信息内容或资料给予任何明示或暗示的保证,包括但不限于为商业使用或适合某一特定的目的的保证,除非有其它特别规定或声明。陆运帮对于因服务、信息内容或资料所产生的任何直接、间接、附带的或因此而导致的连带性损失概不负责。
|
||||
(4)陆运帮尊重他人的权利(包括知识产权),同时也要求会员也尊重他人的权利。陆运帮在适当情况下,可以自行决定终止向违反或侵害他人权利者提供服务。
|
||||
|
||||
</view>
|
||||
|
||||
<view class="section">6、不可抗力条款</view>
|
||||
|
||||
|
||||
|
||||
<view class="section">
|
||||
由于不可抗力或意外事件而影响本应用提供正常的服务和支持时,本应用不承担任何责任。
|
||||
“不可抗力”是指不能预见、不能克服且无法避免的客观事件,如战争、自然灾害、法律法规和政府规范修订、因网络服务特性而特有的原因(如境内外基础电信运营商的故障、计算机或互联网相关技术缺陷、互联网覆盖范围限制、计算机病毒、黑客攻击等因素)等;“意外事件”指诸如光缆出现故障的影响或损坏;通信线路或服务器发生超出本应用防范与预见能力的故障等类似事件。
|
||||
</view>
|
||||
|
||||
<view class="section">7、系统维护</view>
|
||||
|
||||
<view class="section">
|
||||
为提升服务水平,陆运帮在必要时会对本应用、公众号等进行维护,该种情况下需要短时间中断服务,维护通常会在会员休息的时间内进行,也可能在会员正常使用时进行,因此给会员造成的影响陆运帮并不承担任何责任。陆运帮会在时间许可的情况下,会将维护的相关信息以公告的方式通知会员。如因网络通路的偶然阻塞造成本应用访问速度减慢或中断,此种情况属于网络运营商故障,陆运帮对此不负责任,但事后会予以公告。
|
||||
</view>
|
||||
|
||||
|
||||
<view class="section">8、其他</view>
|
||||
|
||||
<view class="section">
|
||||
(1)陆运帮对本服务协议包括基于服务协议制定的各项规则拥有最终解释权。
|
||||
(2)本应用或公众号等由陆运帮提供的服务仅向会员提供服务。会员对本应用或公众号等的使用,即表明同意承担浏览本应用可能带来的各种风险。
|
||||
|
||||
</view>
|
||||
|
||||
<view class="section">9、争议解决</view>
|
||||
|
||||
<view class="section">
|
||||
如使用本协议项下服务中出现纠纷的,您与陆运帮应友好协商解决,若协商不成,您同意将纠纷提交西安市仲裁委员会解决 。
|
||||
</view>
|
||||
14
pages/agreement/login-agree.wxss
Normal file
@@ -0,0 +1,14 @@
|
||||
/* pages/agreement/index.wxss */
|
||||
|
||||
.title {
|
||||
font-size: 32rpx;
|
||||
text-align: center;
|
||||
line-height: 1.6em;
|
||||
}
|
||||
|
||||
.section {
|
||||
font-size: 30rpx;
|
||||
padding: 0.5em 1em;
|
||||
line-height: 1.4em;
|
||||
text-indent: 2em;
|
||||
}
|
||||
66
pages/chooseLib/chooseLib.js
Normal file
@@ -0,0 +1,66 @@
|
||||
// pages/chooseLib/chooseLib.js
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function () {
|
||||
|
||||
}
|
||||
})
|
||||
4
pages/chooseLib/chooseLib.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"navigationBarTitleText": "选择基础库",
|
||||
"usingComponents": {}
|
||||
}
|
||||
14
pages/chooseLib/chooseLib.wxml
Normal file
@@ -0,0 +1,14 @@
|
||||
<!--pages/chooseLib/chooseLib.wxml-->
|
||||
<view class="container">
|
||||
|
||||
<view class="list">
|
||||
<view class="list-item">
|
||||
<text class="black">初始化失败</text>
|
||||
</view>
|
||||
<view class="list-item">
|
||||
<text class="request-text">请使用 2.2.3 或以上的基础库以使用云能力</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
7
pages/chooseLib/chooseLib.wxss
Normal file
@@ -0,0 +1,7 @@
|
||||
/* pages/chooseLib/chooseLib.wxss */
|
||||
|
||||
@import "../../style/guide.wxss";
|
||||
|
||||
.black {
|
||||
color: black;
|
||||
}
|
||||
193
pages/databaseGuide/databaseGuide.js
Normal file
@@ -0,0 +1,193 @@
|
||||
// pages/databaseGuide/databaseGuide.js
|
||||
|
||||
const app = getApp()
|
||||
|
||||
Page({
|
||||
|
||||
data: {
|
||||
step: 1,
|
||||
counterId: '',
|
||||
openid: '',
|
||||
count: null,
|
||||
queryResult: '',
|
||||
},
|
||||
|
||||
onLoad: function (options) {
|
||||
if (app.globalData.openid) {
|
||||
this.setData({
|
||||
openid: app.globalData.openid
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
onAdd: function () {
|
||||
// const db = wx.cloud.database()
|
||||
// db.collection('counters').add({
|
||||
// data: {
|
||||
// count: 1
|
||||
// },
|
||||
// success: res => {
|
||||
// // 在返回结果中会包含新创建的记录的 _id
|
||||
// this.setData({
|
||||
// counterId: res._id,
|
||||
// count: 1
|
||||
// })
|
||||
// wx.showToast({
|
||||
// title: '新增记录成功',
|
||||
// })
|
||||
// console.log('[数据库] [新增记录] 成功,记录 _id: ', res._id)
|
||||
// },
|
||||
// fail: err => {
|
||||
// wx.showToast({
|
||||
// icon: 'none',
|
||||
// title: '新增记录失败'
|
||||
// })
|
||||
// console.error('[数据库] [新增记录] 失败:', err)
|
||||
// }
|
||||
// })
|
||||
},
|
||||
|
||||
onQuery: function() {
|
||||
// const db = wx.cloud.database()
|
||||
// // 查询当前用户所有的 counters
|
||||
// db.collection('counters').where({
|
||||
// _openid: this.data.openid
|
||||
// }).get({
|
||||
// success: res => {
|
||||
// this.setData({
|
||||
// queryResult: JSON.stringify(res.data, null, 2)
|
||||
// })
|
||||
// console.log('[数据库] [查询记录] 成功: ', res)
|
||||
// },
|
||||
// fail: err => {
|
||||
// wx.showToast({
|
||||
// icon: 'none',
|
||||
// title: '查询记录失败'
|
||||
// })
|
||||
// console.error('[数据库] [查询记录] 失败:', err)
|
||||
// }
|
||||
// })
|
||||
},
|
||||
|
||||
onCounterInc: function() {
|
||||
// const db = wx.cloud.database()
|
||||
// const newCount = this.data.count + 1
|
||||
// db.collection('counters').doc(this.data.counterId).update({
|
||||
// data: {
|
||||
// count: newCount
|
||||
// },
|
||||
// success: res => {
|
||||
// this.setData({
|
||||
// count: newCount
|
||||
// })
|
||||
// },
|
||||
// fail: err => {
|
||||
// icon: 'none',
|
||||
// console.error('[数据库] [更新记录] 失败:', err)
|
||||
// }
|
||||
// })
|
||||
},
|
||||
|
||||
onCounterDec: function() {
|
||||
// const db = wx.cloud.database()
|
||||
// const newCount = this.data.count - 1
|
||||
// db.collection('counters').doc(this.data.counterId).update({
|
||||
// data: {
|
||||
// count: newCount
|
||||
// },
|
||||
// success: res => {
|
||||
// this.setData({
|
||||
// count: newCount
|
||||
// })
|
||||
// },
|
||||
// fail: err => {
|
||||
// icon: 'none',
|
||||
// console.error('[数据库] [更新记录] 失败:', err)
|
||||
// }
|
||||
// })
|
||||
},
|
||||
|
||||
onRemove: function() {
|
||||
// if (this.data.counterId) {
|
||||
// const db = wx.cloud.database()
|
||||
// db.collection('counters').doc(this.data.counterId).remove({
|
||||
// success: res => {
|
||||
// wx.showToast({
|
||||
// title: '删除成功',
|
||||
// })
|
||||
// this.setData({
|
||||
// counterId: '',
|
||||
// count: null,
|
||||
// })
|
||||
// },
|
||||
// fail: err => {
|
||||
// wx.showToast({
|
||||
// icon: 'none',
|
||||
// title: '删除失败',
|
||||
// })
|
||||
// console.error('[数据库] [删除记录] 失败:', err)
|
||||
// }
|
||||
// })
|
||||
// } else {
|
||||
// wx.showToast({
|
||||
// title: '无记录可删,请见创建一个记录',
|
||||
// })
|
||||
// }
|
||||
},
|
||||
|
||||
nextStep: function () {
|
||||
// 在第一步,需检查是否有 openid,如无需获取
|
||||
if (this.data.step === 1 && !this.data.openid) {
|
||||
wx.cloud.callFunction({
|
||||
name: 'login',
|
||||
data: {},
|
||||
success: res => {
|
||||
app.globalData.openid = res.result.openid
|
||||
this.setData({
|
||||
step: 2,
|
||||
openid: res.result.openid
|
||||
})
|
||||
},
|
||||
fail: err => {
|
||||
wx.showToast({
|
||||
icon: 'none',
|
||||
title: '获取 openid 失败,请检查是否有部署 login 云函数',
|
||||
})
|
||||
console.log('[云函数] [login] 获取 openid 失败,请检查是否有部署云函数,错误信息:', err)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
const callback = this.data.step !== 6 ? function() {} : function() {
|
||||
console.group('数据库文档')
|
||||
console.log('https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/database.html')
|
||||
console.groupEnd()
|
||||
}
|
||||
|
||||
this.setData({
|
||||
step: this.data.step + 1
|
||||
}, callback)
|
||||
}
|
||||
},
|
||||
|
||||
prevStep: function () {
|
||||
this.setData({
|
||||
step: this.data.step - 1
|
||||
})
|
||||
},
|
||||
|
||||
goHome: function() {
|
||||
const pages = getCurrentPages()
|
||||
if (pages.length === 2) {
|
||||
wx.navigateBack()
|
||||
} else if (pages.length === 1) {
|
||||
wx.redirectTo({
|
||||
url: '../index/index',
|
||||
})
|
||||
} else {
|
||||
wx.reLaunch({
|
||||
url: '../index/index',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
4
pages/databaseGuide/databaseGuide.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"navigationBarTitleText": "数据库指引",
|
||||
"usingComponents": {}
|
||||
}
|
||||
134
pages/databaseGuide/databaseGuide.wxml
Normal file
@@ -0,0 +1,134 @@
|
||||
<!--pages/databaseGuide/databaseGuide.wxml-->
|
||||
<view class="container">
|
||||
|
||||
<!-- 导航 -->
|
||||
<view class="list">
|
||||
<view class="list-item">
|
||||
<text class="request-text">数据库指引</text>
|
||||
</view>
|
||||
<view class="list-item">
|
||||
<text class="request-text" wx:for="{{7}}" style="color: {{step === index + 1 ? 'red': 'black'}}">{{index + 1}}</text>
|
||||
</view>
|
||||
<view class="list-item" wx:if="{{openid}}">
|
||||
<text class="request-text">openid:{{openid}}</text>
|
||||
</view>
|
||||
<view class="list-item" wx:if="{{counterId}}">
|
||||
<text class="request-text">当前记录 ID:{{counterId}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 快速操作数据库指引 -->
|
||||
|
||||
<!-- 简介 -->
|
||||
<view class="guide" wx:if="{{step === 1}}">
|
||||
<text class="headline">示例介绍</text>
|
||||
<text class="p">1. 以计数器为例,在此演示如何操作数据库</text>
|
||||
<text class="p">2. 数据库操作大多需要用户 openid,需先配置好 login 云函数,如已配置好,点击下一步,获取用户 openid 并开始我们的指引</text>
|
||||
<div class="nav">
|
||||
<button class="next" size="mini" type="default" bindtap="nextStep">下一步</button>
|
||||
</div>
|
||||
</view>
|
||||
|
||||
<!-- 新建集合 -->
|
||||
<view class="guide" wx:if="{{step === 2}}">
|
||||
<text class="headline">新建集合</text>
|
||||
<text class="p">1. 打开云开发控制台,进入到数据库管理页</text>
|
||||
<image class="image1" src="../../images/console-entrance.png" mode="aspectFit"></image>
|
||||
<text class="p">2. 选择添加集合,集合名为 counters</text>
|
||||
<image class="flat-image" src="../../images/create-collection.png" mode="aspectFit"></image>
|
||||
<text class="p">3. 可以看到 counters 集合出现在左侧集合列表中</text>
|
||||
<text class="p">注:集合必须在云开发控制台中创建</text>
|
||||
|
||||
<div class="nav">
|
||||
<button class="prev" size="mini" type="default" bindtap="prevStep">上一步</button>
|
||||
<button class="next" size="mini" type="default" bindtap="nextStep">下一步</button>
|
||||
</div>
|
||||
</view>
|
||||
|
||||
<!-- 新增记录 -->
|
||||
<view class="guide" wx:if="{{step === 3}}">
|
||||
<text class="headline">新增记录</text>
|
||||
<text class="p">1. 打开 pages/databaseGuide/databaseGuide.js 文件,定位到 onAdd 方法</text>
|
||||
<text class="p">2. 把注释掉的代码解除注释</text>
|
||||
<image class="code-image" src="../../images/code-db-onAdd.png" mode="aspectFit"></image>
|
||||
<text class="p">3. onAdd 方法会往 counters 集合新增一个记录,新增如下格式的一个 JSON 记录</text>
|
||||
<text class="code">
|
||||
{
|
||||
"_id": "数据库自动生成记录 ID 字段",
|
||||
"_openid": "数据库自动插入记录创建者的 openid",
|
||||
"count": 1
|
||||
}
|
||||
</text>
|
||||
<text class="p">4. 点击按钮</text>
|
||||
<button size="mini" type="default" bindtap="onAdd">新增记录</button>
|
||||
<text class="p" wx:if="{{counterId}}">新增的记录 _id 为:{{counterId}}</text>
|
||||
<text class="p">5. 在云开发 -> 数据库 -> counters 集合中可以看到新增的记录</text>
|
||||
|
||||
<div class="nav">
|
||||
<button class="prev" size="mini" type="default" bindtap="prevStep">上一步</button>
|
||||
<button class="next" size="mini" type="default" bindtap="nextStep" wx:if="{{counterId}}">下一步</button>
|
||||
</div>
|
||||
</view>
|
||||
|
||||
<!-- 查询记录 -->
|
||||
<view class="guide" wx:if="{{step === 4}}">
|
||||
<text class="headline">查询记录</text>
|
||||
<text class="p">1. 打开 pages/databaseGuide/databaseGuide.js 文件,定位到 onQuery 方法</text>
|
||||
<text class="p">2. 把注释掉的代码解除注释,onQuery 方法会在下方按钮被点击时触发</text>
|
||||
<image class="code-image" src="../../images/code-db-onQuery.png" mode="aspectFit"></image>
|
||||
<text class="p">3. 点击按钮</text>
|
||||
<button size="mini" type="default" bindtap="onQuery">查询记录</button>
|
||||
<text class="code" wx:if="{{queryResult}}">{{queryResult}}</text>
|
||||
|
||||
<div class="nav">
|
||||
<button class="prev" size="mini" type="default" bindtap="prevStep">上一步</button>
|
||||
<button class="next" size="mini" type="default" bindtap="nextStep">下一步</button>
|
||||
</div>
|
||||
</view>
|
||||
|
||||
<!-- 更新记录 -->
|
||||
<view class="guide" wx:if="{{step === 5}}">
|
||||
<text class="headline">更新记录</text>
|
||||
<text class="p">1. 打开 pages/databaseGuide/databaseGuide.js 文件,定位到 onCounterInc 和 onCounterDec 方法</text>
|
||||
<text class="p">2. 把注释掉的代码解除注释</text>
|
||||
<image class="code-image" src="../../images/code-db-inc-dec.png" mode="aspectFit"></image>
|
||||
<text class="p">3. 点击下方按钮更新计数器</text>
|
||||
<div class="counter">
|
||||
<button class="minus" size="mini" type="default" bindtap="onCounterDec">-</button>
|
||||
<text class="p">{{count}}</text>
|
||||
<button class="plus" size="mini" type="default" bindtap="onCounterInc">+</button>
|
||||
</div>
|
||||
|
||||
<div class="nav">
|
||||
<button class="prev" size="mini" type="default" bindtap="prevStep">上一步</button>
|
||||
<button class="next" size="mini" type="default" bindtap="nextStep">下一步</button>
|
||||
</div>
|
||||
</view>
|
||||
|
||||
<!-- 删除记录 -->
|
||||
<view class="guide" wx:if="{{step === 6}}">
|
||||
<text class="headline">删除记录</text>
|
||||
<text class="p">1. 打开 pages/databaseGuide/databaseGuide.js 文件,定位到 onRemove 方法</text>
|
||||
<text class="p">2. 把注释掉的代码解除注释</text>
|
||||
<image class="code-image" src="../../images/code-db-onRemove.png" mode="aspectFit"></image>
|
||||
<text class="p">3. 点击下方按钮删除计数器</text>
|
||||
<button size="mini" type="default" bindtap="onRemove">删除记录</button>
|
||||
|
||||
<div class="nav">
|
||||
<button class="prev" size="mini" type="default" bindtap="prevStep" wx:if="{{counterId}}">上一步</button>
|
||||
<button class="next" size="mini" type="default" bindtap="nextStep">下一步</button>
|
||||
</div>
|
||||
</view>
|
||||
|
||||
<!-- 结语 -->
|
||||
<view class="guide" wx:if="{{step === 7}}">
|
||||
<text class="headline">完成指引 !</text>
|
||||
<text class="p">恭喜你,至此已完成数据库操作入门基础,可以点击调试器中的链接,查看详尽的数据库文档</text>
|
||||
|
||||
<div class="nav">
|
||||
<button class="prev" size="mini" type="default" bindtap="prevStep">上一步</button>
|
||||
<button class="next" size="mini" type="default" bindtap="goHome">回到首页</button>
|
||||
</div>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
10
pages/databaseGuide/databaseGuide.wxss
Normal file
@@ -0,0 +1,10 @@
|
||||
/* pages/databaseGuide/databaseGuide.wxss */
|
||||
|
||||
@import "../../style/guide.wxss";
|
||||
|
||||
.guide .counter {
|
||||
margin-top: 50rpx;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-content: space-between;
|
||||
}
|
||||
66
pages/deployFunctions/deployFunctions.js
Normal file
@@ -0,0 +1,66 @@
|
||||
// pages/deployFunctions/deployFunctions.js
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function () {
|
||||
|
||||
}
|
||||
})
|
||||
4
pages/deployFunctions/deployFunctions.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"navigationBarTitleText": "部署云函数",
|
||||
"usingComponents": {}
|
||||
}
|
||||
21
pages/deployFunctions/deployFunctions.wxml
Normal file
@@ -0,0 +1,21 @@
|
||||
<!--pages/deployFunctions/deployFunctions.wxml-->
|
||||
<view class="container">
|
||||
|
||||
<view class="list">
|
||||
<view class="list-item">
|
||||
<text class="black">调用失败</text>
|
||||
</view>
|
||||
<view class="list-item">
|
||||
<text class="request-text">请检查 login 云函数是否已部署</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="guide">
|
||||
<text class="headline">部署 login 云函数</text>
|
||||
<text class="p">1. 确保已通过工具栏云开发入口开通云开发</text>
|
||||
<text class="p">2. 在 cloudfunctions/login 目录上右键上传并部署</text>
|
||||
<text class="p">3. 回到首页,重新点击获取 openid</text>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
7
pages/deployFunctions/deployFunctions.wxss
Normal file
@@ -0,0 +1,7 @@
|
||||
/* pages/deployFunctions/deployFunctions.wxss */
|
||||
|
||||
@import "../../style/guide.wxss";
|
||||
|
||||
.black {
|
||||
color: black;
|
||||
}
|
||||
18
pages/im/im.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const app = getApp()
|
||||
|
||||
Page({
|
||||
data: {
|
||||
},
|
||||
|
||||
onLoad: function (options) {
|
||||
if (app.globalData.openid) {
|
||||
this.setData({
|
||||
openid: app.globalData.openid
|
||||
})
|
||||
}
|
||||
|
||||
console.group('数据库"实时数据推送"文档')
|
||||
console.log('https://developers.weixin.qq.com/miniprogram/dev/wxcloud/guide/database/realtime.html')
|
||||
console.groupEnd()
|
||||
},
|
||||
})
|
||||
4
pages/im/im.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"navigationBarTitleText": "数据库指引",
|
||||
"usingComponents": {}
|
||||
}
|
||||
21
pages/im/im.wxml
Normal file
@@ -0,0 +1,21 @@
|
||||
<view class="container">
|
||||
<!-- 简介 -->
|
||||
<view class="guide">
|
||||
<text class="headline">即时通信 demo 介绍</text>
|
||||
<text class="p">本 demo 以《聊天室》为例,在此演示如何使用数据库《实时数据推送》能力</text>
|
||||
<text class="p">1. 确保正在使用基础库 2.8.1</text>
|
||||
<text class="p">2. 打开云开发控制台,进入到数据库管理页</text>
|
||||
<text class="p">3. 选择添加集合,集合名设置为 chatroom</text>
|
||||
<text class="p">4. 将集合设置为所有用户可读、仅创建者可写</text>
|
||||
<text class="p">5. 确保IDE增强编译已开启(如无,到工具详情页中开启)</text>
|
||||
<text class="p">6. 点击下方按钮进入聊天室!</text>
|
||||
<text class="p">注1:可使用(菜单栏-工具)多账号调试的功能在工具中模拟多账号登录调试</text>
|
||||
<text class="p">注2:实时数据推送的文档链接已在调试器中打印,可打开查看</text>
|
||||
</view>
|
||||
|
||||
<view class="uploader">
|
||||
<navigator url="./room/room" open-type="navigate" class="uploader-text">
|
||||
<text>进入聊天室</text>
|
||||
</navigator>
|
||||
</view>
|
||||
</view>
|
||||
10
pages/im/im.wxss
Normal file
@@ -0,0 +1,10 @@
|
||||
/* pages/databaseGuide/databaseGuide.wxss */
|
||||
|
||||
@import "../../style/guide.wxss";
|
||||
|
||||
.guide .counter {
|
||||
margin-top: 50rpx;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-content: space-between;
|
||||
}
|
||||
88
pages/im/room/index.js
Normal file
@@ -0,0 +1,88 @@
|
||||
//index.js
|
||||
const app = getApp()
|
||||
|
||||
Page({
|
||||
data: {
|
||||
avatarUrl: './user-unlogin.png',
|
||||
userInfo: null,
|
||||
logged: false,
|
||||
takeSession: false,
|
||||
requestResult: '',
|
||||
chatRoomEnvId: 'release-f8415a',
|
||||
chatRoomCollection: 'kecun',
|
||||
chatRoomGroupId: 'tit-bricker',
|
||||
chatRoomGroupName: '深夜话题',
|
||||
|
||||
// functions for used in chatroom components
|
||||
onGetUserInfo: null,
|
||||
getOpenID: null,
|
||||
},
|
||||
|
||||
onLoad: function() {
|
||||
// 获取用户信息
|
||||
wx.getSetting({
|
||||
success: res => {
|
||||
if (res.authSetting['scope.userInfo']) {
|
||||
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
|
||||
wx.getUserInfo({
|
||||
success: res => {
|
||||
this.setData({
|
||||
avatarUrl: res.userInfo.avatarUrl,
|
||||
userInfo: res.userInfo
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
this.setData({
|
||||
onGetUserInfo: this.onGetUserInfo,
|
||||
getOpenID: this.getOpenID,
|
||||
})
|
||||
|
||||
wx.getSystemInfo({
|
||||
success: res => {
|
||||
console.log('system info', res)
|
||||
if (res.safeArea) {
|
||||
const { top, bottom } = res.safeArea
|
||||
this.setData({
|
||||
containerStyle: `padding-top: ${(/ios/i.test(res.system) ? 10 : 20) + top}px; padding-bottom: ${20 + res.windowHeight - bottom}px`,
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
|
||||
getOpenID: async function() {
|
||||
if (this.openid) {
|
||||
return this.openid
|
||||
}
|
||||
|
||||
const { result } = await wx.cloud.callFunction({
|
||||
name: 'login',
|
||||
config: {
|
||||
env: 'release-f8415a',
|
||||
},
|
||||
})
|
||||
|
||||
return result.openid
|
||||
},
|
||||
|
||||
onGetUserInfo: function(e) {
|
||||
if (!this.logged && e.detail.userInfo) {
|
||||
this.setData({
|
||||
logged: true,
|
||||
avatarUrl: e.detail.userInfo.avatarUrl,
|
||||
userInfo: e.detail.userInfo
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
onShareAppMessage() {
|
||||
return {
|
||||
title: '深夜话题',
|
||||
path: '/pages/index/index',
|
||||
}
|
||||
},
|
||||
})
|
||||
84
pages/im/room/room.js
Normal file
@@ -0,0 +1,84 @@
|
||||
const app = getApp()
|
||||
|
||||
Page({
|
||||
data: {
|
||||
avatarUrl: './user-unlogin.png',
|
||||
userInfo: null,
|
||||
logged: false,
|
||||
takeSession: false,
|
||||
requestResult: '',
|
||||
// chatRoomEnvId: 'release-f8415a',
|
||||
chatRoomCollection: 'chatroom',
|
||||
chatRoomGroupId: 'demo',
|
||||
chatRoomGroupName: '聊天室',
|
||||
|
||||
// functions for used in chatroom components
|
||||
onGetUserInfo: null,
|
||||
getOpenID: null,
|
||||
},
|
||||
|
||||
onLoad: function() {
|
||||
// 获取用户信息
|
||||
wx.getSetting({
|
||||
success: res => {
|
||||
if (res.authSetting['scope.userInfo']) {
|
||||
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
|
||||
wx.getUserInfo({
|
||||
success: res => {
|
||||
this.setData({
|
||||
avatarUrl: res.userInfo.avatarUrl,
|
||||
userInfo: res.userInfo
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
this.setData({
|
||||
onGetUserInfo: this.onGetUserInfo,
|
||||
getOpenID: this.getOpenID,
|
||||
})
|
||||
|
||||
wx.getSystemInfo({
|
||||
success: res => {
|
||||
console.log('system info', res)
|
||||
if (res.safeArea) {
|
||||
const { top, bottom } = res.safeArea
|
||||
this.setData({
|
||||
containerStyle: `padding-top: ${(/ios/i.test(res.system) ? 10 : 20) + top}px; padding-bottom: ${20 + res.windowHeight - bottom}px`,
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
|
||||
getOpenID: async function() {
|
||||
if (this.openid) {
|
||||
return this.openid
|
||||
}
|
||||
|
||||
const { result } = await wx.cloud.callFunction({
|
||||
name: 'login',
|
||||
})
|
||||
|
||||
return result.openid
|
||||
},
|
||||
|
||||
onGetUserInfo: function(e) {
|
||||
if (!this.logged && e.detail.userInfo) {
|
||||
this.setData({
|
||||
logged: true,
|
||||
avatarUrl: e.detail.userInfo.avatarUrl,
|
||||
userInfo: e.detail.userInfo
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
onShareAppMessage() {
|
||||
return {
|
||||
title: '即时通信 Demo',
|
||||
path: '/pages/im/room/room',
|
||||
}
|
||||
},
|
||||
})
|
||||
5
pages/im/room/room.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"chatroom": "/components/chatroom/chatroom"
|
||||
}
|
||||
}
|
||||
12
pages/im/room/room.wxml
Normal file
@@ -0,0 +1,12 @@
|
||||
<view class="container" style="{{containerStyle}}">
|
||||
<chatroom
|
||||
style="width: 100%; height: 100%"
|
||||
envId="{{chatRoomEnvId}}"
|
||||
collection="{{chatRoomCollection}}"
|
||||
groupId="{{chatRoomGroupId}}"
|
||||
groupName="{{chatRoomGroupName}}"
|
||||
userInfo="{{userInfo}}"
|
||||
onGetUserInfo="{{onGetUserInfo}}"
|
||||
getOpenID="{{getOpenID}}"
|
||||
></chatroom>
|
||||
</view>
|
||||
10
pages/im/room/room.wxss
Normal file
@@ -0,0 +1,10 @@
|
||||
.container {
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
padding-top: 80rpx;
|
||||
padding-bottom: 30rpx;
|
||||
}
|
||||
BIN
pages/images/RILI_111.gif
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
pages/images/arrow_down.png
Normal file
|
After Width: | Height: | Size: 381 B |
BIN
pages/images/delet.png
Normal file
|
After Width: | Height: | Size: 856 B |
BIN
pages/images/edit.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
pages/images/headshot.png
Normal file
|
After Width: | Height: | Size: 31 KiB |
BIN
pages/images/huoche.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
pages/images/ic_form_hide1.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
pages/images/ic_form_hide2.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
pages/images/ic_list_account.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
pages/images/ic_list_arrow.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
pages/images/ic_list_change.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
pages/images/ic_list_company.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
pages/images/ic_list_history.png
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
pages/images/ic_list_money_back.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
pages/images/ic_list_password.png
Normal file
|
After Width: | Height: | Size: 2.5 KiB |
BIN
pages/images/ic_list_pay_card.png
Normal file
|
After Width: | Height: | Size: 6.6 KiB |
BIN
pages/images/ic_list_pay_discount.png
Normal file
|
After Width: | Height: | Size: 8.0 KiB |
BIN
pages/images/ic_list_pay_wallet.png
Normal file
|
After Width: | Height: | Size: 8.1 KiB |
BIN
pages/images/ic_list_price.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
pages/images/ic_oil_pay_credit.png
Normal file
|
After Width: | Height: | Size: 6.9 KiB |
BIN
pages/images/ic_tab_mine_off.png
Normal file
|
After Width: | Height: | Size: 5.9 KiB |
BIN
pages/images/ic_tab_mine_on.png
Normal file
|
After Width: | Height: | Size: 6.4 KiB |
BIN
pages/images/ic_tab_record_off.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
pages/images/ic_tab_record_on.png
Normal file
|
After Width: | Height: | Size: 6.6 KiB |
BIN
pages/images/jiashiyuan.png
Normal file
|
After Width: | Height: | Size: 6.7 KiB |
BIN
pages/images/jiayouedu.png
Normal file
|
After Width: | Height: | Size: 6.3 KiB |
BIN
pages/images/seting.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
pages/images/statistics.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
pages/images/statisticsActive.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
pages/images/you.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
120
pages/index/index.js
Normal file
@@ -0,0 +1,120 @@
|
||||
//index.js
|
||||
const app = getApp()
|
||||
|
||||
Page({
|
||||
data: {
|
||||
avatarUrl: './user-unlogin.png',
|
||||
userInfo: {},
|
||||
logged: false,
|
||||
takeSession: false,
|
||||
requestResult: ''
|
||||
},
|
||||
|
||||
onLoad: function() {
|
||||
if (!wx.cloud) {
|
||||
wx.redirectTo({
|
||||
url: '../chooseLib/chooseLib',
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
// 获取用户信息
|
||||
wx.getSetting({
|
||||
success: res => {
|
||||
if (res.authSetting['scope.userInfo']) {
|
||||
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
|
||||
wx.getUserInfo({
|
||||
success: res => {
|
||||
this.setData({
|
||||
avatarUrl: res.userInfo.avatarUrl,
|
||||
userInfo: res.userInfo
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
onGetUserInfo: function(e) {
|
||||
if (!this.data.logged && e.detail.userInfo) {
|
||||
this.setData({
|
||||
logged: true,
|
||||
avatarUrl: e.detail.userInfo.avatarUrl,
|
||||
userInfo: e.detail.userInfo
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
onGetOpenid: function() {
|
||||
// 调用云函数
|
||||
wx.cloud.callFunction({
|
||||
name: 'login',
|
||||
data: {},
|
||||
success: res => {
|
||||
console.log('[云函数] [login] user openid: ', res.result.openid)
|
||||
app.globalData.openid = res.result.openid
|
||||
wx.navigateTo({
|
||||
url: '../userConsole/userConsole',
|
||||
})
|
||||
},
|
||||
fail: err => {
|
||||
console.error('[云函数] [login] 调用失败', err)
|
||||
wx.navigateTo({
|
||||
url: '../deployFunctions/deployFunctions',
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 上传图片
|
||||
doUpload: function () {
|
||||
// 选择图片
|
||||
wx.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['compressed'],
|
||||
sourceType: ['album', 'camera'],
|
||||
success: function (res) {
|
||||
|
||||
wx.showLoading({
|
||||
title: '上传中',
|
||||
})
|
||||
|
||||
const filePath = res.tempFilePaths[0]
|
||||
|
||||
// 上传图片
|
||||
const cloudPath = 'my-image' + filePath.match(/\.[^.]+?$/)[0]
|
||||
wx.cloud.uploadFile({
|
||||
cloudPath,
|
||||
filePath,
|
||||
success: res => {
|
||||
console.log('[上传文件] 成功:', res)
|
||||
|
||||
app.globalData.fileID = res.fileID
|
||||
app.globalData.cloudPath = cloudPath
|
||||
app.globalData.imagePath = filePath
|
||||
|
||||
wx.navigateTo({
|
||||
url: '../storageConsole/storageConsole'
|
||||
})
|
||||
},
|
||||
fail: e => {
|
||||
console.error('[上传文件] 失败:', e)
|
||||
wx.showToast({
|
||||
icon: 'none',
|
||||
title: '上传失败',
|
||||
})
|
||||
},
|
||||
complete: () => {
|
||||
wx.hideLoading()
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
fail: e => {
|
||||
console.error(e)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
})
|
||||
3
pages/index/index.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
||||
59
pages/index/index.wxml
Normal file
@@ -0,0 +1,59 @@
|
||||
<!--index.wxml-->
|
||||
<view class="container">
|
||||
|
||||
<!-- 用户 openid -->
|
||||
<view class="userinfo">
|
||||
<button
|
||||
open-type="getUserInfo"
|
||||
bindgetuserinfo="onGetUserInfo"
|
||||
class="userinfo-avatar"
|
||||
style="background-image: url({{avatarUrl}})"
|
||||
size="default"
|
||||
></button>
|
||||
<view class="userinfo-nickname-wrapper">
|
||||
<button class="userinfo-nickname" bindtap="onGetOpenid">点击获取 openid</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<!-- 上传图片 -->
|
||||
<view class="uploader">
|
||||
<view class="uploader-text" bindtap="doUpload">
|
||||
<text>上传图片</text>
|
||||
</view>
|
||||
<view class="uploader-container" wx:if="{{imgUrl}}">
|
||||
<image class="uploader-image" src="{{imgUrl}}" mode="aspectFit" bindtap="previewImg"></image>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<!-- 操作数据库 -->
|
||||
<view class="uploader">
|
||||
<navigator url="../databaseGuide/databaseGuide" open-type="navigate" class="uploader-text">
|
||||
<text>前端操作数据库</text>
|
||||
</navigator>
|
||||
</view>
|
||||
|
||||
<!-- 即时通信 -->
|
||||
<view class="uploader">
|
||||
<navigator url="../im/im" open-type="navigate" class="uploader-text">
|
||||
<text>即时通信 Demo</text>
|
||||
</navigator>
|
||||
</view>
|
||||
|
||||
<!-- 新建云函数 -->
|
||||
<view class="uploader">
|
||||
<navigator url="../addFunction/addFunction" open-type="navigate" class="uploader-text">
|
||||
<text>快速新建云函数</text>
|
||||
</navigator>
|
||||
</view>
|
||||
|
||||
<!-- 云调用 -->
|
||||
<view class="uploader">
|
||||
<navigator url="../openapi/openapi" open-type="navigate" class="uploader-text">
|
||||
<text>云调用</text>
|
||||
</navigator>
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
||||
153
pages/index/index.wxss
Normal file
@@ -0,0 +1,153 @@
|
||||
/**index.wxss**/
|
||||
|
||||
page {
|
||||
background: #f6f6f6;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.userinfo, .uploader, .tunnel {
|
||||
margin-top: 40rpx;
|
||||
height: 140rpx;
|
||||
width: 100%;
|
||||
background: #fff;
|
||||
border: 1px solid rgba(0, 0, 0, 0.1);
|
||||
border-left: none;
|
||||
border-right: none;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
transition: all 300ms ease;
|
||||
}
|
||||
|
||||
.userinfo {
|
||||
padding-left: 120rpx;
|
||||
}
|
||||
|
||||
.userinfo-avatar {
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
margin: 20rpx;
|
||||
border-radius: 50%;
|
||||
background-size: cover;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.userinfo-avatar[size] {
|
||||
width: 100rpx;
|
||||
}
|
||||
|
||||
|
||||
.userinfo-avatar:after {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.userinfo-nickname {
|
||||
font-size: 32rpx;
|
||||
color: #007aff;
|
||||
background-color: white;
|
||||
background-size: cover;
|
||||
text-align: left;
|
||||
padding-left: 0;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.userinfo-nickname::after {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.userinfo-nickname-wrapper {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.uploader, .tunnel {
|
||||
height: auto;
|
||||
padding: 0 0 0 40rpx;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.uploader-text, .tunnel-text {
|
||||
width: 100%;
|
||||
line-height: 52px;
|
||||
font-size: 34rpx;
|
||||
color: #007aff;
|
||||
}
|
||||
|
||||
.uploader-container {
|
||||
width: 100%;
|
||||
height: 400rpx;
|
||||
padding: 20rpx 20rpx 20rpx 0;
|
||||
display: flex;
|
||||
align-content: center;
|
||||
justify-content: center;
|
||||
box-sizing: border-box;
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.uploader-image {
|
||||
width: 100%;
|
||||
height: 360rpx;
|
||||
}
|
||||
|
||||
.tunnel {
|
||||
padding: 0 0 0 40rpx;
|
||||
}
|
||||
|
||||
.tunnel-text {
|
||||
position: relative;
|
||||
color: #222;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-content: center;
|
||||
justify-content: space-between;
|
||||
box-sizing: border-box;
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.tunnel-text:first-child {
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
.tunnel-switch {
|
||||
position: absolute;
|
||||
right: 20rpx;
|
||||
top: -2rpx;
|
||||
}
|
||||
|
||||
.disable {
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.service {
|
||||
position: fixed;
|
||||
right: 40rpx;
|
||||
bottom: 40rpx;
|
||||
width: 140rpx;
|
||||
height: 140rpx;
|
||||
border-radius: 50%;
|
||||
background: linear-gradient(#007aff, #0063ce);
|
||||
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.3);
|
||||
display: flex;
|
||||
align-content: center;
|
||||
justify-content: center;
|
||||
transition: all 300ms ease;
|
||||
}
|
||||
|
||||
.service-button {
|
||||
position: absolute;
|
||||
top: 40rpx;
|
||||
}
|
||||
|
||||
.service:active {
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.request-text {
|
||||
padding: 20rpx 0;
|
||||
font-size: 24rpx;
|
||||
line-height: 36rpx;
|
||||
word-break: break-all;
|
||||
}
|
||||
BIN
pages/index/user-unlogin.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
55
pages/limitDetail/limitDetail.js
Normal file
@@ -0,0 +1,55 @@
|
||||
const app = getApp();
|
||||
|
||||
Page({
|
||||
data: {
|
||||
userInfo: {
|
||||
namePhone: '',
|
||||
vehicle: ''
|
||||
},
|
||||
walletList: [],
|
||||
// 此页面 页面内容距最顶部的距离
|
||||
height: app.globalData.height,
|
||||
nvabarData: {
|
||||
showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
|
||||
title: "额度查询结果", //导航栏 中间的标题
|
||||
}
|
||||
},
|
||||
|
||||
onLoad: function(options) {
|
||||
// 获取事件通道
|
||||
const eventChannel = this.getOpenerEventChannel();
|
||||
|
||||
// 监听limitData事件,获取上一页面传递的数据
|
||||
eventChannel.on('limitData', (data) => {
|
||||
console.log('接收到的数据:', data);
|
||||
this.processData(data.walletList);
|
||||
});
|
||||
},
|
||||
|
||||
// 处理数据
|
||||
processData: function(data) {
|
||||
// 检查数据是否有效
|
||||
if (data && data.length > 0) {
|
||||
// 从第一个元素获取用户基本信息
|
||||
const firstItem = data[0];
|
||||
|
||||
// 格式化姓名和手机号
|
||||
const namePhone = `${firstItem.auName}-${firstItem.phone}`;
|
||||
|
||||
this.setData({
|
||||
userInfo: {
|
||||
namePhone: namePhone,
|
||||
vehicle: firstItem.vehicle || '未设置'
|
||||
},
|
||||
walletList: data
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 返回上一页
|
||||
navigateBack: function() {
|
||||
wx.navigateBack({
|
||||
delta: 1
|
||||
});
|
||||
}
|
||||
});
|
||||
8
pages/limitDetail/limitDetail.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"navigationBarTitleText": "额度查询结果",
|
||||
"navigationBarBackgroundColor": "#3C80F6",
|
||||
"navigationBarTextStyle": "white",
|
||||
"usingComponents": {
|
||||
"nav-bar": "/components/navbarMyOil/index"
|
||||
}
|
||||
}
|
||||
45
pages/limitDetail/limitDetail.wxml
Normal file
@@ -0,0 +1,45 @@
|
||||
<view class="wrapper">
|
||||
<view class="header">
|
||||
<view class="nav" style='height: {{height*2 + 10}}px;padding-top:{{height-10}}px;'>
|
||||
<!-- 返回按钮 -->
|
||||
<view class="nav-back" bindtap="navigateBack">
|
||||
<image class="back-icon" src="/pages/images/you.png" mode="aspectFill" />
|
||||
</view>
|
||||
<!-- 页面标题 -->
|
||||
<view class="nav-title">额度查询结果</view>
|
||||
</view>
|
||||
<view class="info">
|
||||
<view class="info-item">
|
||||
<image class="info-icon user-icon" src="../images/jiashiyuan.png" mode="widthFix" />
|
||||
<text class="info-value">{{userInfo.namePhone}}</text>
|
||||
</view>
|
||||
<view class="info-item">
|
||||
<image class="info-icon vehicle-icon" src="../images/huoche.png" mode="widthFix" />
|
||||
<text class="info-value">{{userInfo.vehicle}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="body">
|
||||
<!-- <view class="section-title">钱包信息</view> -->
|
||||
|
||||
<!-- 钱包卡片列表 -->
|
||||
<view class="wallet-list">
|
||||
<view class="wallet-card" wx:for="{{walletList}}" wx:key="index">
|
||||
<view class="card-header">
|
||||
<text class="tenant-name">{{item.tenantName}}</text>
|
||||
</view>
|
||||
<view class="card-body">
|
||||
<view class="balance-item">
|
||||
<text class="balance-label">钱包余额</text>
|
||||
<text class="balance-value" data-value="{{item.walletMoney}}">{{item.walletMoney}}</text>
|
||||
</view>
|
||||
<view class="balance-item">
|
||||
<text class="balance-label">油卡余额</text>
|
||||
<text class="balance-value oil-card" data-value="{{item.oilWallet}}">{{item.oilWallet}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
366
pages/limitDetail/limitDetail.wxss
Normal file
@@ -0,0 +1,366 @@
|
||||
/* 基础样式 */
|
||||
.wrapper {
|
||||
height: 100%;
|
||||
background: #f5f7fa;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* 头部样式 */
|
||||
.header {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 300rpx;
|
||||
flex-shrink: 0;
|
||||
background: linear-gradient(115deg, #62B2FF -1.34%, #3C80F6 100%);
|
||||
}
|
||||
|
||||
.nav {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
box-sizing: border-box;
|
||||
color: #ffffff;
|
||||
text-align: center;
|
||||
font-size: 34rpx;
|
||||
font-weight: 500;
|
||||
padding-left: 34rpx;
|
||||
}
|
||||
|
||||
/* 返回按钮样式 */
|
||||
.nav-back {
|
||||
width: 44rpx;
|
||||
height: 44rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.back-icon {
|
||||
width: 24rpx;
|
||||
height: 24rpx;
|
||||
}
|
||||
|
||||
/* 页面标题样式 */
|
||||
.nav-title {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
font-size: 34rpx;
|
||||
font-weight: 500;
|
||||
color: #ffffff;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: calc(var(--status-bar-height) + 10px);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* 用户信息样式 */
|
||||
.info {
|
||||
padding: 40rpx 32rpx 0;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 20rpx;
|
||||
justify-content: space-between;
|
||||
width: calc(100% - 64rpx);
|
||||
}
|
||||
|
||||
.info-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 18rpx 20rpx;
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
border-radius: 15rpx;
|
||||
backdrop-filter: blur(10rpx);
|
||||
flex: 1;
|
||||
margin: 0 5rpx;
|
||||
box-sizing: border-box;
|
||||
overflow: visible;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.info-label {
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
font-size: 28rpx;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.info-value {
|
||||
color: #ffffff;
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
overflow: visible;
|
||||
text-overflow: clip;
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
/* 信息图标样式 */
|
||||
.info-icon {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
margin-right: 15rpx;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.user-icon {
|
||||
width: 45rpx;
|
||||
height: 45rpx;
|
||||
}
|
||||
|
||||
.vehicle-icon {
|
||||
width: 42rpx;
|
||||
height: 42rpx;
|
||||
}
|
||||
|
||||
/* 主体内容样式 */
|
||||
.body {
|
||||
flex: 1;
|
||||
background-color: #f5f7fa;
|
||||
width: 100%;
|
||||
/* padding: 120rpx 24rpx 30rpx; */
|
||||
box-sizing: border-box;
|
||||
overflow-y: auto;
|
||||
margin-top: 5rpx;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
/* 响应式调整 */
|
||||
@media screen and (min-width: 750rpx) {
|
||||
.wallet-card {
|
||||
max-width: 600rpx;
|
||||
margin: 0 auto 28rpx;
|
||||
}
|
||||
|
||||
.body {
|
||||
padding: 120rpx 40rpx 30rpx;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 375rpx) {
|
||||
.info-item {
|
||||
padding: 15rpx 20rpx;
|
||||
}
|
||||
|
||||
.card-body {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.tenant-name {
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.balance-value {
|
||||
font-size: 30rpx;
|
||||
}
|
||||
}
|
||||
|
||||
/* 标题样式 */
|
||||
.section-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
margin-bottom: 25rpx;
|
||||
padding-left: 10rpx;
|
||||
}
|
||||
|
||||
/* 钱包列表样式 */
|
||||
.wallet-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20rpx;
|
||||
animation: fadeInUp 0.6s ease-out;
|
||||
}
|
||||
|
||||
/* 页面淡入动画 */
|
||||
@keyframes fadeInUp {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(30rpx);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* 卡片滑入动画 */
|
||||
@keyframes slideUp {
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* 数字滚动动画 */
|
||||
@keyframes countUp {
|
||||
from {
|
||||
transform: translateY(100%);
|
||||
}
|
||||
to {
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* 应用数字动画 */
|
||||
.balance-value {
|
||||
display: inline-block;
|
||||
overflow: hidden;
|
||||
vertical-align: bottom;
|
||||
animation: countUp 1s ease-out forwards;
|
||||
transform: translateY(100%);
|
||||
}
|
||||
|
||||
/* 钱包卡片样式 */
|
||||
.wallet-card {
|
||||
background: #fff;
|
||||
border-radius: 24rpx;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.08);
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
position: relative;
|
||||
margin-bottom: 28rpx;
|
||||
animation: slideUp 0.5s ease-out forwards;
|
||||
opacity: 0;
|
||||
transform: translateY(50rpx);
|
||||
}
|
||||
|
||||
.wallet-card:nth-child(1) {
|
||||
animation-delay: 0.1s;
|
||||
}
|
||||
|
||||
.wallet-card:nth-child(2) {
|
||||
animation-delay: 0.2s;
|
||||
}
|
||||
|
||||
.wallet-card:nth-child(3) {
|
||||
animation-delay: 0.3s;
|
||||
}
|
||||
|
||||
.wallet-card::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 8rpx;
|
||||
background: linear-gradient(115deg, #62B2FF -1.34%, #3C80F6 100%);
|
||||
opacity: 0;
|
||||
transition: opacity 0.3s ease;
|
||||
}
|
||||
|
||||
.wallet-card:active {
|
||||
transform: translateY(4rpx);
|
||||
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
|
||||
.wallet-card:active::before {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
/* 卡片头部样式 */
|
||||
.card-header {
|
||||
padding: 30rpx 35rpx;
|
||||
background: linear-gradient(115deg, #62B2FF -1.34%, #3C80F6 100%);
|
||||
color: #fff;
|
||||
border-radius: 0 0 20rpx 20rpx;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.card-header::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: -100%;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
|
||||
transition: left 0.5s ease;
|
||||
}
|
||||
|
||||
.wallet-card:active .card-header::after {
|
||||
left: 100%;
|
||||
}
|
||||
|
||||
.tenant-name {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
display: block;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
letter-spacing: 1rpx;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
padding: 0 20rpx;
|
||||
}
|
||||
|
||||
/* 卡片主体样式 */
|
||||
.card-body {
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
/* 余额项样式 */
|
||||
.balance-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 20rpx 0;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
}
|
||||
|
||||
.balance-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.balance-label {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.balance-value {
|
||||
font-size: 34rpx;
|
||||
color: #4facfe;
|
||||
font-weight: 700;
|
||||
font-family: 'Arial', sans-serif;
|
||||
letter-spacing: 1rpx;
|
||||
}
|
||||
|
||||
.balance-value.oil-card {
|
||||
color: #43e97b;
|
||||
}
|
||||
|
||||
/* 金额样式 */
|
||||
.balance-value::before {
|
||||
content: '¥';
|
||||
font-size: 26rpx;
|
||||
margin-right: 5rpx;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
/* 空状态样式 */
|
||||
.empty-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 100rpx 0;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.empty-icon {
|
||||
width: 150rpx;
|
||||
height: 150rpx;
|
||||
margin-bottom: 20rpx;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 28rpx;
|
||||
}
|
||||
205
pages/login-wx/login-wx.js
Normal file
@@ -0,0 +1,205 @@
|
||||
const app = getApp();
|
||||
var http = require("../../utils/http.js");
|
||||
Page({
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
code: "",
|
||||
check: false,
|
||||
nvabarData: {
|
||||
showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
|
||||
title: "微信登录", //导航栏 中间的标题
|
||||
},
|
||||
|
||||
// 此页面 页面内容距最顶部的距离
|
||||
height: app.globalData.height * 2 + 20,
|
||||
picImg: http.picImg
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) { },
|
||||
// 监听单选
|
||||
radiocon: function () {
|
||||
this.setData({
|
||||
check: !this.data.check,
|
||||
});
|
||||
},
|
||||
getPhoneNumber(e) {
|
||||
if (!this.data.check) {
|
||||
this.showDialogBtn();
|
||||
return;
|
||||
}
|
||||
console.log('11111')
|
||||
this.w_login(e.detail.iv, e.detail.encryptedData);
|
||||
},
|
||||
showDialogBtn: function () {
|
||||
wx.showModal({
|
||||
content: "请阅读并勾选注册服务协议",
|
||||
showCancel: false,
|
||||
});
|
||||
},
|
||||
w_login: function (iv, encryptedData) {
|
||||
var that = this;
|
||||
wx.login({
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
that.setData({
|
||||
code: res.code,
|
||||
});
|
||||
that.getPhone(iv, encryptedData);
|
||||
} else {
|
||||
console.log("登录失败!" + res.errMsg);
|
||||
}
|
||||
},
|
||||
fail: function () {
|
||||
wx.hideLoading();
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "网络连接异常",
|
||||
showCancel: false,
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
getPhone: function (ivParameter, enData) {
|
||||
console.log('3333')
|
||||
var that = this;
|
||||
var sessionKey = wx.getStorageSync("sessionKey");
|
||||
wx.request({
|
||||
url: app.globalData.devUrl + "/api/v1/cooperation/bindByWx",
|
||||
data: {
|
||||
iv: ivParameter,
|
||||
encryptedData: enData,
|
||||
sessionkey: sessionKey,
|
||||
},
|
||||
success: function (res) {
|
||||
if (res.data.code == 0) {
|
||||
wx.setStorageSync("phoneSupply", res.data.data.phone);
|
||||
that.Login(res.data.data.phone);
|
||||
} else {
|
||||
// wx.showModal({
|
||||
// title: '提示',
|
||||
// content: res.data.msg,
|
||||
// showCancel: false,
|
||||
// })
|
||||
}
|
||||
},
|
||||
fail: function () {
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "网络连接异常",
|
||||
showCancel: false,
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
Login: function (phone) {
|
||||
wx.showLoading({
|
||||
title: "加载中...",
|
||||
});
|
||||
wx.request({
|
||||
url: app.globalData.devUrl + "/api/v1/cooperation/login",
|
||||
method: "POST",
|
||||
header: {
|
||||
"content-type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
data: {
|
||||
phone: phone,
|
||||
weChatId: wx.getStorageSync("weChatId"),
|
||||
},
|
||||
success: function (res) {
|
||||
wx.hideLoading();
|
||||
if (res.data.code == 0) {
|
||||
if (res.data.data.state === 0) {
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "您的手机号暂未绑定加油站信息",
|
||||
showCancel: false,
|
||||
});
|
||||
} else {
|
||||
if (res.data.data.cooperations) {
|
||||
wx.setStorageSync("cooperations", res.data.data.cooperations);
|
||||
}
|
||||
if (res.data.data.cooperation) {
|
||||
wx.setStorageSync("cooperation", res.data.data.cooperation);
|
||||
}
|
||||
wx.setStorageSync('kybUser', res.data.data.kybUser)
|
||||
wx.reLaunch({
|
||||
url: "/pages/oilManage/oilManage",
|
||||
});
|
||||
}
|
||||
} else {
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: res.data.msg,
|
||||
showCancel: false,
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function (res) {
|
||||
wx.hideLoading();
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: res.data.msg,
|
||||
showCancel: false,
|
||||
});
|
||||
},
|
||||
fail: function () {
|
||||
wx.hideLoading();
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "网络连接异常",
|
||||
showCancel: false,
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
sign: function () {
|
||||
var that = this;
|
||||
if (that.data.check) {
|
||||
wx.navigateTo({
|
||||
url: "/pages/login/login",
|
||||
});
|
||||
} else {
|
||||
that.showDialogBtn();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () { },
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () { },
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () { },
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () { },
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () { },
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () { },
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function () { },
|
||||
});
|
||||
5
pages/login-wx/login-wx.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"nav-bar": "/components/navbarWeChat/index"
|
||||
}
|
||||
}
|
||||
35
pages/login-wx/login-wx.wxml
Normal file
@@ -0,0 +1,35 @@
|
||||
<!-- <nav-bar navbar-data='{{nvabarData}}'></nav-bar> -->
|
||||
<!-- <view class='home-page' style='margin-top: {{height}}px'>
|
||||
<view class="ylcy">
|
||||
<image src="../images/wx2.png" mode="Original image" style='margin-top:50rpx'></image>
|
||||
<button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber" style='margin-top:80rpx' hover-class="button">
|
||||
手机号快捷登录
|
||||
</button>
|
||||
<view class="sign" bindtap='sign'>输入手机号码登录</view>
|
||||
</view>
|
||||
<view class="sign-xie">
|
||||
<radio checked='{{check}}' bindtap='radiocon' color='#3965ff'></radio>
|
||||
*登录或注册表示同意
|
||||
<navigator open-type="navigate" catchtap="catchMove" url="/pages/agreement/login-agree" style="display: inline; border-bottom: 1px solid #ccc;">
|
||||
《陆运帮客户端注册服务协议》
|
||||
</navigator>
|
||||
</view>
|
||||
</view> -->
|
||||
|
||||
<view>
|
||||
<image src="{{picImg}}bg_login.png" class='bg_login' />
|
||||
<view class='content'>
|
||||
<image src="{{picImg}}bg_login_logo.png" class='bg_login_logo' />
|
||||
<button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber" hover-class="button" class='wxLogin'>
|
||||
手机号快捷登录
|
||||
</button>
|
||||
<button bindtap='sign' hover-class="button" class='wxLoginPhone'>手机验证码登录</button>
|
||||
<view class="sign-xie">
|
||||
<radio checked='{{check}}' bindtap='radiocon' color='#3965ff'></radio>
|
||||
我已阅读并同意
|
||||
<navigator open-type="navigate" catchtap="catchMove" url="/pages/agreement/login-agree" class='navigator'>
|
||||
《陆运帮客户端服务协议》
|
||||
</navigator>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
122
pages/login-wx/login-wx.wxss
Normal file
@@ -0,0 +1,122 @@
|
||||
/* .ylcy {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
image {
|
||||
width: 330rpx;
|
||||
height: 240rpx;
|
||||
}
|
||||
|
||||
button {
|
||||
width: 90%;
|
||||
height: 90rpx;
|
||||
line-height: 90rpx;
|
||||
background: #1aac19;
|
||||
border-radius: 5rpx;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.wx {
|
||||
width: 50rpx;
|
||||
height: 40rpx;
|
||||
vertical-align: middle;
|
||||
margin-left: 15rpx;
|
||||
margin-top: -5px;
|
||||
}
|
||||
|
||||
.sign {
|
||||
margin-top: 30rpx;
|
||||
color: #778caf;
|
||||
font-size: 16px;
|
||||
letter-spacing: 2rpx;
|
||||
}
|
||||
|
||||
.sign-xie {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin-top: 30rpx;
|
||||
color: #778caf;
|
||||
font-size: 24rpx;
|
||||
letter-spacing: 2rpx;
|
||||
text-align: center;
|
||||
}
|
||||
.sign-xie radio {
|
||||
zoom: 0.7;
|
||||
} */
|
||||
.bg_login {
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.content {
|
||||
position: relative;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.bg_login_logo {
|
||||
width: 233px;
|
||||
margin: 142px 0 40px 0;
|
||||
height: 64px;
|
||||
}
|
||||
|
||||
button {
|
||||
margin-top: 24px;
|
||||
color: #ffffff !important;
|
||||
font-size: 32rpx;
|
||||
padding: 0;
|
||||
background-color: #fff !important;
|
||||
border-radius: 0;
|
||||
display: inline-block !important;
|
||||
line-height: normal !important;
|
||||
}
|
||||
|
||||
.wxLogin {
|
||||
width: 278px;
|
||||
height: 48px;
|
||||
padding: 13px 80px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
font-size: 16px;
|
||||
border-radius: 8px;
|
||||
letter-spacing: 0.5px;
|
||||
background: linear-gradient(115deg, #62B2FF -1.34%, #3C80F6 100%);
|
||||
}
|
||||
|
||||
.wxLoginPhone {
|
||||
width: 278px;
|
||||
height: 48px;
|
||||
padding: 13px 0;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
border-radius: 8px;
|
||||
border: 1px solid #62B2FF;
|
||||
color: #367df9 !important;
|
||||
font-size: 16px;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.sign-xie {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin-top: 30rpx;
|
||||
color: #808080;
|
||||
font-size: 24rpx;
|
||||
letter-spacing: 2rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.sign-xie radio {
|
||||
zoom: 0.6;
|
||||
margin: 2px 2px 0 0;
|
||||
}
|
||||
.navigator{
|
||||
color:#367DF9
|
||||
}
|
||||
363
pages/login/login.js
Normal file
@@ -0,0 +1,363 @@
|
||||
const app = getApp()
|
||||
var http = require("../../utils/http.js");
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
phone: "",
|
||||
password: "",
|
||||
_num: 1,
|
||||
codeDis: true,
|
||||
phoneCode: "验证码",
|
||||
nvabarData: {
|
||||
showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
|
||||
title: '登录', //导航栏 中间的标题
|
||||
},
|
||||
|
||||
// 此页面 页面内容距最顶部的距离
|
||||
height: app.globalData.height * 2 + 20,
|
||||
picImg:http.picImg
|
||||
},
|
||||
|
||||
w_login: function (iv, encryptedData) {
|
||||
var that = this;
|
||||
wx.login({
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
that.setData({
|
||||
code: res.code,
|
||||
});
|
||||
that.getPhone(iv, encryptedData);
|
||||
} else {
|
||||
console.log("登录失败!" + res.errMsg);
|
||||
}
|
||||
},
|
||||
fail: function () {
|
||||
wx.hideLoading();
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "网络连接异常",
|
||||
showCancel: false,
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
getPhoneNumber(e) {
|
||||
this.w_login(e.detail.iv, e.detail.encryptedData);
|
||||
},
|
||||
getPhone: function (ivParameter, enData) {
|
||||
var that = this;
|
||||
var sessionKey = wx.getStorageSync("sessionKey");
|
||||
wx.request({
|
||||
url: app.globalData.devUrl + "/api/v1/cooperation/bindByWx",
|
||||
data: {
|
||||
iv: ivParameter,
|
||||
encryptedData: enData,
|
||||
sessionkey: sessionKey,
|
||||
},
|
||||
success: function (res) {
|
||||
if (res.data.code == 0) {
|
||||
wx.setStorageSync("phoneSupply", res.data.data.phone);
|
||||
that.Login(res.data.data.phone);
|
||||
} else {
|
||||
// wx.showModal({
|
||||
// title: '提示',
|
||||
// content: res.data.msg,
|
||||
// showCancel: false,
|
||||
// })
|
||||
}
|
||||
},
|
||||
fail: function () {
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "网络连接异常",
|
||||
showCancel: false,
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
Login: function (phone) {
|
||||
wx.showLoading({
|
||||
title: "加载中...",
|
||||
});
|
||||
wx.request({
|
||||
url: app.globalData.devUrl + "/api/v1/cooperation/login",
|
||||
method: "POST",
|
||||
header: {
|
||||
"content-type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
data: {
|
||||
phone: phone,
|
||||
weChatId: wx.getStorageSync("weChatId"),
|
||||
},
|
||||
success: function (res) {
|
||||
wx.hideLoading();
|
||||
if (res.data.code == 0) {
|
||||
if (res.data.data.state === 0) {
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "您的手机号暂未绑定加油站信息",
|
||||
showCancel: false,
|
||||
});
|
||||
} else {
|
||||
console.log(1111,res.data)
|
||||
if(res.data.cooperations){
|
||||
wx.setStorageSync("cooperations", res.data.cooperations);
|
||||
}
|
||||
if(res.data.data.cooperation){
|
||||
wx.setStorageSync("cooperation", res.data.data.cooperation);
|
||||
}
|
||||
wx.reLaunch({
|
||||
url: "/pages/oilManage/oilManage",
|
||||
});
|
||||
}
|
||||
} else {
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: res.data.msg,
|
||||
showCancel: false,
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function (res) {
|
||||
wx.hideLoading();
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: res.data.msg,
|
||||
showCancel: false,
|
||||
});
|
||||
},
|
||||
fail: function () {
|
||||
wx.hideLoading();
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "网络连接异常",
|
||||
showCancel: false,
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
phoneinput(e) {
|
||||
let value = e.detail.value
|
||||
this.setData({
|
||||
telephone: value
|
||||
})
|
||||
},
|
||||
codeinput(e) {
|
||||
let value = e.detail.value
|
||||
this.setData({
|
||||
codePhone: value
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function () { },
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function () { },
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function () { },
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function () {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function () {
|
||||
|
||||
},
|
||||
//获取用户输入
|
||||
phone: function (e) {
|
||||
this.setData({
|
||||
phone: e.detail.value
|
||||
})
|
||||
},
|
||||
password: function (e) {
|
||||
this.setData({
|
||||
password: e.detail.value
|
||||
})
|
||||
},
|
||||
getMa: function (e) {
|
||||
var that = this;
|
||||
if (that.data.phoneCode == '验证码' || that.data.phoneCode == 0) {
|
||||
if (!that.data.phone) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '请输入手机号',
|
||||
showCancel: false,
|
||||
})
|
||||
return;
|
||||
}
|
||||
wx.showLoading({
|
||||
title: '加载中....',
|
||||
});
|
||||
wx.request({
|
||||
type: "POST",
|
||||
header: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
url: app.globalData.devUrl + "/api/v1/cooperation/register/code",
|
||||
data: {
|
||||
phone: that.data.phone,
|
||||
},
|
||||
error: function (data) {
|
||||
wx.hideLoading()
|
||||
wx.showToast({
|
||||
title: '呜呜呜,出问题了'
|
||||
});
|
||||
that.setData({
|
||||
phoneCode: "",
|
||||
codeDis: false
|
||||
})
|
||||
},
|
||||
success: function (data) {
|
||||
wx.hideLoading()
|
||||
if (data.data.code == 0) {
|
||||
wx.showToast({
|
||||
title: '请查收短信'
|
||||
});
|
||||
that.setData({
|
||||
phoneCode: 60,
|
||||
codeDis: true
|
||||
})
|
||||
let time = setInterval(() => {
|
||||
let phoneCode = that.data.phoneCode
|
||||
phoneCode--
|
||||
that.setData({
|
||||
phoneCode: phoneCode
|
||||
})
|
||||
if (phoneCode == 0) {
|
||||
clearInterval(time)
|
||||
that.setData({
|
||||
phoneCode: "验证码",
|
||||
codeDis: false
|
||||
})
|
||||
}
|
||||
}, 1000)
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: data.data.msg
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: function (data) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '网络传输异常',
|
||||
showCancel: false,
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
loginIn: function () {
|
||||
console.log('25555')
|
||||
var that = this;
|
||||
if (that.data.phone == "" || that.data.password == "") {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '请检查输入项',
|
||||
showCancel: false,
|
||||
})
|
||||
return;
|
||||
}
|
||||
var phone = that.data.phone;
|
||||
var password = that.data.password;
|
||||
wx.showLoading({
|
||||
title: '加载中....',
|
||||
});
|
||||
wx.request({
|
||||
url: app.globalData.devUrl + "/api/v1/cooperation/login",
|
||||
header: {
|
||||
'content-type': 'application/x-www-form-urlencoded'
|
||||
},
|
||||
method: "POST",
|
||||
data: {
|
||||
phone: phone,
|
||||
code: password,
|
||||
role: 1,
|
||||
weChatId: wx.getStorageSync("weChatId"),
|
||||
paltform: 2,
|
||||
},
|
||||
success: function (res) {
|
||||
wx.hideLoading()
|
||||
if (res.data.code == 0) {
|
||||
if (res.data.data.state === 0) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '您的手机号暂未绑定加油站信息',
|
||||
showCancel: false
|
||||
})
|
||||
} else {
|
||||
if (res.data.data.cooperations) {
|
||||
wx.setStorageSync("cooperations", res.data.data.cooperations);
|
||||
}
|
||||
if (res.data.data.cooperation) {
|
||||
wx.setStorageSync("cooperation", res.data.data.cooperation);
|
||||
}
|
||||
wx.setStorageSync('kybUser', res.data.data.kybUser)
|
||||
wx.reLaunch({
|
||||
url: '/pages/oilManage/oilManage',
|
||||
})
|
||||
}
|
||||
} else {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: res.data.msg,
|
||||
showCancel: false,
|
||||
})
|
||||
}
|
||||
},
|
||||
error: function (res) {
|
||||
wx.hideLoading()
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: res.data.msg,
|
||||
showCancel: false,
|
||||
})
|
||||
},
|
||||
fail: function (data) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '网络传输异常',
|
||||
showCancel: false,
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
5
pages/login/login.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"nav-bar": "/components/navbarTwo/index"
|
||||
}
|
||||
}
|
||||
16
pages/login/login.wxml
Normal file
@@ -0,0 +1,16 @@
|
||||
<!-- <nav-bar navbar-data='{{nvabarData}}'></nav-bar> -->
|
||||
<view>
|
||||
<image src="{{picImg}}bg_login.png" class='bg_login' />
|
||||
<view class='content'>
|
||||
<image src="{{picImg}}bg_login_logo.png" class='bg_login_logo' />
|
||||
<input class='input-box phone' type='number' bindinput="phone" placeholder='请输入手机号码' placeholder-class="pla" maxlength='11' value='{{phone}}'></input>
|
||||
<view class='yzm'>
|
||||
<input class='input-box phone' type='number' bindinput="password" placeholder='请输入验证码' placeholder-class="pla" maxlength='6' value='{{password}}'></input>
|
||||
<view class='getCode' catchtap="getMa">{{phoneCode!='验证码'?phoneCode+'s':phoneCode}}</view>
|
||||
</view>
|
||||
<view bindtap="loginIn" class='loginIn'>立即登录</view>
|
||||
<button open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber" hover-class="button">
|
||||
手机号快捷登录
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
104
pages/login/login.wxss
Normal file
@@ -0,0 +1,104 @@
|
||||
.btn-s {
|
||||
height: 60rpx;
|
||||
line-height: 60rpx;
|
||||
border: 1px solid #056399;
|
||||
background: #056399;
|
||||
font-size: 34rpx;
|
||||
border-radius: 2px;
|
||||
letter-spacing: 0px;
|
||||
width: 240rpx;
|
||||
text-align: center;
|
||||
float: right;
|
||||
}
|
||||
|
||||
.bg_login {
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.content {
|
||||
text-align: center;
|
||||
position: relative;
|
||||
z-index: 99;
|
||||
}
|
||||
|
||||
.bg_login_logo {
|
||||
width: 233px;
|
||||
margin: 142px 0 40px 0;
|
||||
height: 64px;
|
||||
}
|
||||
|
||||
.loginIn {
|
||||
margin: 0 auto;
|
||||
width: 287px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
flex-shrink: 0;
|
||||
border-radius: 8px;
|
||||
color: #ffffff;
|
||||
font-size: 16px;
|
||||
line-height: 40px;
|
||||
letter-spacing: 0.5px;
|
||||
margin-top: 64px;
|
||||
background: linear-gradient(115deg, #62B2FF -1.34%, #3C80F6 100%);
|
||||
}
|
||||
|
||||
.input-box {
|
||||
margin: 16px 17px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.phone {
|
||||
padding: 10px 12px;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
border-radius: 8px;
|
||||
opacity: 0.95;
|
||||
background: #FFF;
|
||||
}
|
||||
|
||||
.pla {
|
||||
color: #808080;
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
text-align: left;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.getCode {
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
border-radius: 4px;
|
||||
background: #367DF9;
|
||||
color: #ffffff;
|
||||
font-size: 13px;
|
||||
width: 55px;
|
||||
height: 26px;
|
||||
line-height: 26px;
|
||||
position: absolute;
|
||||
right: 29px;
|
||||
top: 7px;
|
||||
z-index:99;
|
||||
}
|
||||
|
||||
.yzm {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
button {
|
||||
margin-top: 64px;
|
||||
color: #367df9!important;
|
||||
font-size: 32rpx;
|
||||
padding: 0;
|
||||
background-color: #fff !important;
|
||||
border-radius: 0;
|
||||
display: inline-block !important;
|
||||
line-height: normal !important;
|
||||
}
|
||||
|
||||
button::after {
|
||||
border: none;
|
||||
}
|
||||
130
pages/oilHistory/oilHistory.js
Normal file
@@ -0,0 +1,130 @@
|
||||
const app = getApp();
|
||||
var http = require("../../utils/http.js");
|
||||
Page({
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
picImg:http.picImg,
|
||||
current: 1,
|
||||
size: 20,
|
||||
nvabarData: {
|
||||
showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
|
||||
title: "历史油价", //导航栏 中间的标题
|
||||
},
|
||||
stationName: "",
|
||||
oilPriceList: [],
|
||||
total: 0,
|
||||
// 此页面 页面内容距最顶部的距离
|
||||
height: app.globalData.height * 2 + 20,
|
||||
currentCooPrice:'',
|
||||
currentPrice:''
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad() {
|
||||
this.getOilHistory();
|
||||
const cooperation = wx.getStorageSync("cooperation");
|
||||
this.setData({
|
||||
stationName: cooperation.company,
|
||||
settlementType:cooperation.settlementType//1--价格 2--公斤
|
||||
});
|
||||
},
|
||||
|
||||
getOilHistory: function () {
|
||||
var that = this;
|
||||
|
||||
wx.request({
|
||||
url:
|
||||
app.globalData.devUrl +
|
||||
`/zx/user/coo-user-history/${
|
||||
wx.getStorageSync("cooperation").id
|
||||
}?current=${that.data.current}&size=20`,
|
||||
method: `GET`,
|
||||
header: {
|
||||
"content-type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
success: function (res) {
|
||||
if (res.data.code == "0000") {
|
||||
let newData = that.data.oilPriceList;
|
||||
if (that.data.current === 1) {
|
||||
newData = res.data.data.records;
|
||||
} else {
|
||||
newData = newData.concat(res.data.data.records);
|
||||
}
|
||||
that.setData({
|
||||
oilPriceList: newData,
|
||||
total: res.data.data.total,
|
||||
currentCooPrice:newData[0].cooPrice,
|
||||
currentPrice:newData[0].price,
|
||||
});
|
||||
}
|
||||
wx.stopPullDownRefresh()
|
||||
},
|
||||
error: function () {
|
||||
console.log(res);
|
||||
},
|
||||
fail: function (data) {
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "网络传输异常",
|
||||
showCancel: false,
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
const current = 1;
|
||||
this.setData({
|
||||
current,
|
||||
});
|
||||
this.getOilHistory();
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
if (this.data.oilPriceList.length >= this.data.total) {
|
||||
wx.showToast({
|
||||
title: "没有更多数据了",
|
||||
});
|
||||
} else {
|
||||
const current = this.data.current + 1;
|
||||
this.setData({
|
||||
current,
|
||||
});
|
||||
this.getOilHistory();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {},
|
||||
});
|
||||
7
pages/oilHistory/oilHistory.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"enablePullDownRefresh": true,
|
||||
"backgroundTextStyle": "dark",
|
||||
"usingComponents": {
|
||||
"nav-bar": "/components/navbarMyOil/index"
|
||||
}
|
||||
}
|
||||
35
pages/oilHistory/oilHistory.wxml
Normal file
@@ -0,0 +1,35 @@
|
||||
<nav-bar navbar-data='{{nvabarData}}'></nav-bar>
|
||||
<view style='padding: {{height}}px 0 50px 0'>
|
||||
<view class="containers">
|
||||
<view class='Big'>
|
||||
<image src='{{picImg}}statistics_bg.png' class='new_bg'></image>
|
||||
<view class='myBox' style='top: {{height}}px'>
|
||||
<view class='stationName'>{{stationName}}</view>
|
||||
<view class='oilInfo'>
|
||||
<view class='priceOil'>
|
||||
<view class='currentPrice'>{{currentCooPrice||'--'}}</view>
|
||||
<view class='currentPriceTips'>当前挂牌价 (元)</view>
|
||||
</view>
|
||||
<view class='priceOil kilogram' wx:if="{{settlementType==2}}">
|
||||
<view class='currentPrice'>{{currentPrice||'--'}}</view>
|
||||
<view class='currentPriceTips'>站点优惠价 (元)</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class='record'>调价记录</view>
|
||||
<view wx:for="{{oilPriceList}}" wx:key="id" class='listContent'>
|
||||
<view class='historyPrice'>
|
||||
<view>
|
||||
<view class='userDate'>{{item.userDate}}</view>
|
||||
<view class='userName'>{{item.userName}}</view>
|
||||
</view>
|
||||
<view class='cooPrice typeOil' wx:if="{{settlementType==1}}"> {{item.cooPrice||'--'}}</view>
|
||||
<view class='typeOil' wx:else>
|
||||
<view class='cooPriceGJ'> {{item.cooPrice||'--'}}</view>
|
||||
<view class='price'> {{item.price||'--'}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
117
pages/oilHistory/oilHistory.wxss
Normal file
@@ -0,0 +1,117 @@
|
||||
.containers {
|
||||
min-height: 100%;
|
||||
margin: 0 17px 100px 17px;
|
||||
}
|
||||
|
||||
.stationName {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.new_bg {
|
||||
width: 100%;
|
||||
height: 302rpx;
|
||||
}
|
||||
|
||||
.Big {
|
||||
width: 100%;
|
||||
margin: 10rpx auto;
|
||||
}
|
||||
|
||||
.userName {
|
||||
width: 84px !important;
|
||||
}
|
||||
|
||||
.record {
|
||||
line-height: 41px;
|
||||
color: #393939;
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
margin-top: -238rpx;
|
||||
}
|
||||
|
||||
.historyPrice {
|
||||
padding: 12px 12px 8px 12px;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
border-radius: 8px;
|
||||
background: #FFF;
|
||||
box-shadow: 0 0 4px 0 #F3F5F7;
|
||||
display: flex;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.userDate {
|
||||
color: #808080;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.userName {
|
||||
color: #363636;
|
||||
font-size: 14px;
|
||||
margin-top: 10.5px;
|
||||
}
|
||||
|
||||
.cooPrice {
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.price {
|
||||
color: #363636;
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.typeOil {
|
||||
position: absolute;
|
||||
right: 29px;
|
||||
}
|
||||
|
||||
.cooPriceGJ {
|
||||
color: #808080;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.myBox {
|
||||
position: relative;
|
||||
margin: 12px 0 0 12px;
|
||||
letter-spacing: 0.9px;
|
||||
top: -302rpx !important;
|
||||
}
|
||||
|
||||
.stationName {
|
||||
color: #ffffff;
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.currentPrice {
|
||||
color: #ffffff;
|
||||
font-size: 24px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.currentPriceTips {
|
||||
color: #ffffff;
|
||||
font-size: 16px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.oilInfo {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin-top: 24px;
|
||||
}
|
||||
|
||||
.priceOil {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.kilogram {
|
||||
margin-left: 50rpx;
|
||||
}
|
||||
81
pages/oilManage/datapick.js
Normal file
@@ -0,0 +1,81 @@
|
||||
function withData(param) {
|
||||
return param < 10 ? '0' + param : '' + param;
|
||||
}
|
||||
function getLoopArray(start, end) {
|
||||
var start = start || 0;
|
||||
var end = end || 1;
|
||||
var array = [];
|
||||
for (var i = start; i <= end; i++) {
|
||||
array.push(withData(i));
|
||||
}
|
||||
return array;
|
||||
}
|
||||
function getMonthDay(year, month) {
|
||||
var flag = year % 400 == 0 || (year % 4 == 0 && year % 100 != 0), array = null;
|
||||
|
||||
switch (month) {
|
||||
case '01':
|
||||
case '03':
|
||||
case '05':
|
||||
case '07':
|
||||
case '08':
|
||||
case '10':
|
||||
case '12':
|
||||
array = getLoopArray(1, 31)
|
||||
break;
|
||||
case '04':
|
||||
case '06':
|
||||
case '09':
|
||||
case '11':
|
||||
array = getLoopArray(1, 30)
|
||||
break;
|
||||
case '02':
|
||||
array = flag ? getLoopArray(1, 29) : getLoopArray(1, 28)
|
||||
break;
|
||||
default:
|
||||
array = '月份格式不正确,请重新输入!'
|
||||
}
|
||||
return array;
|
||||
}
|
||||
function getNewDateArry() {
|
||||
// 当前时间的处理
|
||||
var newDate = new Date();
|
||||
var year = withData(newDate.getFullYear()),
|
||||
mont = withData(newDate.getMonth() + 1),
|
||||
date = withData(newDate.getDate()),
|
||||
hour = withData(newDate.getHours()),
|
||||
minu = withData(newDate.getMinutes()),
|
||||
seco = withData(newDate.getSeconds());
|
||||
|
||||
return [year, mont, date, hour, minu, seco];
|
||||
}
|
||||
function dateTimePicker(startYear, endYear, date) {
|
||||
// 返回默认显示的数组和联动数组的声明
|
||||
var dateTime = [], dateTimeArray = [[], [], [], [], [], []];
|
||||
var start = startYear || 1978;
|
||||
var end = endYear || 2100;
|
||||
// 默认开始显示数据
|
||||
var defaultDate = date ? [...date.split(' ')[0].split('-'), ...date.split(' ')[1].split(':')] : getNewDateArry();
|
||||
// 处理联动列表数据
|
||||
/*年月日 时分秒*/
|
||||
dateTimeArray[0] = getLoopArray(start, end);
|
||||
dateTimeArray[1] = getLoopArray(1, 12);
|
||||
dateTimeArray[2] = getMonthDay(defaultDate[0], defaultDate[1]);
|
||||
dateTimeArray[3] = getLoopArray(0, 23);
|
||||
dateTimeArray[4] = getLoopArray(0, 59);
|
||||
dateTimeArray[5] = getLoopArray(0, 59);
|
||||
|
||||
dateTimeArray.forEach((current, index) => {
|
||||
dateTime.push(current.indexOf(defaultDate[index]));
|
||||
});
|
||||
|
||||
return {
|
||||
dateTimeArray: dateTimeArray,
|
||||
dateTime: dateTime
|
||||
}
|
||||
}
|
||||
module.exports = {
|
||||
dateTimePicker: dateTimePicker,
|
||||
getMonthDay: getMonthDay
|
||||
}
|
||||
|
||||
492
pages/oilManage/oilManage.js
Normal file
@@ -0,0 +1,492 @@
|
||||
var loadMoreView, page;
|
||||
const http = require("../../utils/http");
|
||||
const { qcodePay } = require("../../utils/qrPay");
|
||||
const { timeStr } = require("../../utils/util.js");
|
||||
const app = getApp();
|
||||
const host = app.globalData.devUrl;
|
||||
const max10000Reg =
|
||||
/^\d\.([1-9]{1,2}|[0-9][1-9])$|^[1-9]\d{0,3}(\.\d{1,2}){0,1}$/;
|
||||
const max100Reg =
|
||||
/^\d\.([1-9]{1,2}|[0-9][1-9])$|^[1-9]\d{0,1}(\.\d{1,2}){0,1}$/;
|
||||
Page({
|
||||
/* 页面的初始数据*/
|
||||
data: {
|
||||
picImg: http.picImg,
|
||||
system: {},
|
||||
items: [],
|
||||
selectedView: "article",
|
||||
start: "",
|
||||
end: "",
|
||||
// 此页面 页面内容距最顶部的距离
|
||||
height: app.globalData.height,
|
||||
showInputModal: false,
|
||||
moneyTotal: 0,
|
||||
offersMoneyTotal: 0,
|
||||
gasReceiptsTotal: 0,
|
||||
money: "",
|
||||
oilQuantity: "", //加油量
|
||||
oilQuantityTotal: 0, //加油量统计
|
||||
showOilModal: false,
|
||||
price: "",
|
||||
cooPrice: "", // 挂牌价
|
||||
offersMoney: "",
|
||||
settlementType: 1, // 1价格战 2公斤站
|
||||
userType: 0, // 0 负责人 1 站员
|
||||
stationName: "",
|
||||
isTriggered: false,
|
||||
showDateTimePick: false,
|
||||
pickerConfig: {
|
||||
endDate: true,
|
||||
column: "second",
|
||||
dateLimit: true,
|
||||
initStartTime: '',
|
||||
initEndTime: '',
|
||||
limitStartTime: "",
|
||||
limitEndTime: ""
|
||||
},
|
||||
startView: '',
|
||||
endView: '',
|
||||
totalPages: 0,
|
||||
showList: true,
|
||||
},
|
||||
|
||||
|
||||
handleScrollToLower() {
|
||||
loadMoreView.loadMore(page);
|
||||
},
|
||||
handleRefresherRefresh() {
|
||||
page = 1
|
||||
this.loadData(0);
|
||||
},
|
||||
showDateTimePick() {
|
||||
this.setData({
|
||||
showDateTimePick: !this.data.showDateTimePick
|
||||
})
|
||||
},
|
||||
setPickerTime(e) {
|
||||
const { startTime, endTime } = e.detail
|
||||
const startView = timeStr(new Date(startTime))
|
||||
const endView = timeStr(new Date(endTime))
|
||||
this.setData({
|
||||
start: startTime,
|
||||
end: endTime,
|
||||
startView,
|
||||
endView
|
||||
})
|
||||
console.log(startView, 'startView');
|
||||
console.log(endView, 'endView');
|
||||
this.showDateTimePick()
|
||||
this.loadData(0);
|
||||
},
|
||||
showModal() {
|
||||
this.setData({
|
||||
money: "",
|
||||
showInputModal: true,
|
||||
});
|
||||
},
|
||||
|
||||
hiddenModal() {
|
||||
this.setData({
|
||||
money: "",
|
||||
showInputModal: false,
|
||||
});
|
||||
},
|
||||
seting() {
|
||||
wx.navigateTo({
|
||||
url: "/pages/wodeOil/wodeOil",
|
||||
});
|
||||
},
|
||||
//修改油价
|
||||
editPriceHandle() {
|
||||
this.setData({
|
||||
showOilModal: true,
|
||||
});
|
||||
},
|
||||
|
||||
closeModal() {
|
||||
this.setData({
|
||||
showOilModal: false,
|
||||
});
|
||||
},
|
||||
setPrice(e) {
|
||||
var price;
|
||||
if (/^(\d?)+(\.\d{0,2})?$/.test(e.detail.value)) {
|
||||
price = e.detail.value;
|
||||
} else {
|
||||
price = e.detail.value.substring(0, e.detail.value.length - 1);
|
||||
}
|
||||
this.setData({
|
||||
price: price,
|
||||
});
|
||||
},
|
||||
|
||||
setOffersMoney(e) {
|
||||
var price;
|
||||
if (/^(\d?)+(\.\d{0,2})?$/.test(e.detail.value)) {
|
||||
price = e.detail.value;
|
||||
} else {
|
||||
price = e.detail.value.substring(0, e.detail.value.length - 1);
|
||||
}
|
||||
this.setData({
|
||||
offersMoney: price,
|
||||
});
|
||||
},
|
||||
//提交修改油价
|
||||
editOil() {
|
||||
var that = this;
|
||||
if (that.data.price == "") {
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "请输入挂牌价!",
|
||||
showCancel: false,
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!max100Reg.test(that.data.price)) {
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "请输入0-100以内的数字",
|
||||
showCancel: false,
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (that.data.settlementType === 2 && that.data.offersMoney == "") {
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "请输入站点优惠价!",
|
||||
showCancel: false,
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (
|
||||
that.data.settlementType === 2 &&
|
||||
that.data.offersMoney &&
|
||||
!max100Reg.test(that.data.offersMoney)
|
||||
) {
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "请输入0-100以内的数字,请输入0-100以内的数字",
|
||||
showCancel: false,
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (+that.data.offersMoney > +that.data.price) {
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "站点优惠价不可高于挂牌价!",
|
||||
showCancel: false,
|
||||
});
|
||||
return;
|
||||
}
|
||||
return new Promise((reslove, reject) => {
|
||||
wx.request({
|
||||
url: `${host}/api/v1/cooperation/update/price`,
|
||||
method: `POST`,
|
||||
header: {
|
||||
"content-type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
data: {
|
||||
id: wx.getStorageSync("cooperation").id,
|
||||
price: that.data.price,
|
||||
offersMoney: that.data.offersMoney || 0,
|
||||
},
|
||||
success: function (e) {
|
||||
if (e.data.code === 0) {
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "修改成功",
|
||||
showCancel: false,
|
||||
});
|
||||
that.closeModal();
|
||||
that.setData({
|
||||
cooPrice: e.data.cooPrice,
|
||||
price: "",
|
||||
offersMoney: "",
|
||||
});
|
||||
reslove(e.data);
|
||||
that.loadData(0);
|
||||
} else {
|
||||
reject(e.data);
|
||||
}
|
||||
},
|
||||
fail: function (e) {
|
||||
reject(e);
|
||||
},
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
setMoney(e) {
|
||||
var money;
|
||||
if (/^(\d?)+(\.\d{0,2})?$/.test(e.detail.value)) {
|
||||
money = e.detail.value;
|
||||
} else {
|
||||
money = e.detail.value.substring(0, e.detail.value.length - 1);
|
||||
}
|
||||
this.setData({
|
||||
money,
|
||||
});
|
||||
},
|
||||
|
||||
setOilQuantity(e) {
|
||||
var oilQuantity;
|
||||
if (/^(\d?)+(\.\d{0,2})?$/.test(e.detail.value)) {
|
||||
oilQuantity = e.detail.value;
|
||||
} else {
|
||||
oilQuantity = e.detail.value.substring(0, e.detail.value.length - 1);
|
||||
}
|
||||
this.setData({
|
||||
oilQuantity,
|
||||
});
|
||||
},
|
||||
// 扫码收钱
|
||||
getMoney() {
|
||||
const money = this.data.money;
|
||||
const oilQuantity = this.data.oilQuantity;
|
||||
if (this.data.settlementType === 1 && !money) return;
|
||||
if (this.data.settlementType === 1 && money && !max10000Reg.test(money)) {
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "请输入0-10000以内的数字!",
|
||||
showCancel: false,
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (this.data.settlementType === 2 && !oilQuantity) return;
|
||||
if (
|
||||
this.data.settlementType === 2 &&
|
||||
oilQuantity &&
|
||||
!max10000Reg.test(oilQuantity)
|
||||
) {
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "请输入0-10000以内的数字",
|
||||
showCancel: false,
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.hiddenModal();
|
||||
wx.showLoading();
|
||||
wx.scanCode({
|
||||
// onlyFromCamera: true,
|
||||
scanType: ["qrCode"],
|
||||
success: (e) => {
|
||||
try {
|
||||
const data = JSON.parse(e.result);
|
||||
if (money) {
|
||||
data.totalMoney = money;
|
||||
}
|
||||
if (oilQuantity) {
|
||||
data.oilQuantity = oilQuantity;
|
||||
}
|
||||
// const nonceStr = data.nonceStr;
|
||||
// const fillingTime = data.fillingTime;
|
||||
// const merchantNum = data.merchantNum;
|
||||
// const orderNo = data.orderNo;
|
||||
data.sign = 123;
|
||||
qcodePay(data)
|
||||
.then((e) => {
|
||||
if (e.code == "0000") {
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: `收款成功`,
|
||||
showCancel: false,
|
||||
});
|
||||
}
|
||||
wx.hideLoading();
|
||||
this.onPullDownRefresh();
|
||||
})
|
||||
.catch((e) => {
|
||||
wx.hideLoading();
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
showCancel: false,
|
||||
content: e.msg ? e.msg : `未知错误,请稍后再试`,
|
||||
});
|
||||
});
|
||||
} catch (e) {
|
||||
wx.hideLoading();
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "这不是一个有效的二维码",
|
||||
showCancel: false,
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: (e) => {
|
||||
// wx.showToast({
|
||||
// title: '没有发现二维码',
|
||||
// icon: 'none'
|
||||
// })
|
||||
wx.hideLoading();
|
||||
},
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function () {},
|
||||
|
||||
onShow() {
|
||||
page = 1;
|
||||
var that = this;
|
||||
loadMoreView = this.selectComponent("#loadMoreView");
|
||||
const { settlementType, company } = wx.getStorageSync("cooperation");
|
||||
const userType = wx.getStorageSync("kybUser").userType;
|
||||
this.setData({
|
||||
userType,
|
||||
settlementType,
|
||||
stationName: company,
|
||||
});
|
||||
wx.getSystemInfo({
|
||||
success: function (res) {
|
||||
that.setData({
|
||||
system: res,
|
||||
});
|
||||
},
|
||||
});
|
||||
this.loadData(0);
|
||||
},
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function () {
|
||||
page = 1;
|
||||
this.setData({
|
||||
start: "",
|
||||
end: "",
|
||||
});
|
||||
this.loadData(0);
|
||||
// http.weChat()
|
||||
},
|
||||
loadData: function (offset = 0) {
|
||||
const startTime =
|
||||
this.data.start ||
|
||||
timeStr(
|
||||
new Date(new Date().toLocaleDateString()).getTime(),
|
||||
"YYYY-MM-DD hh:mm:ss"
|
||||
);
|
||||
this.setData({
|
||||
start: startTime,
|
||||
startView: timeStr(new Date(startTime)),
|
||||
'pickerConfig.initStartTime': startTime
|
||||
});
|
||||
|
||||
const endTime = this.data.end || timeStr(new Date(new Date().toLocaleDateString()).getTime() + 24 * 60 * 60 * 1000 - 1, "YYYY-MM-DD hh:mm:ss");
|
||||
console.log(endTime, 'endTime');
|
||||
this.setData({
|
||||
end: endTime,
|
||||
endView: timeStr(new Date(endTime)),
|
||||
'pickerConfig.initEndTime': endTime,
|
||||
'pickerConfig.limitEndTime': endTime
|
||||
});
|
||||
console.log(startTime, 'startTime');
|
||||
console.log(this.data.startView, 'startView');
|
||||
console.log(endTime, 'endTime');
|
||||
console.log(this.data.endView, 'endView');
|
||||
var that = this;
|
||||
var uuid = wx.getStorageSync("cooperation").id;
|
||||
wx.showLoading({
|
||||
title: "加载中",
|
||||
mask: true,
|
||||
});
|
||||
wx.showNavigationBarLoading();
|
||||
wx.request({
|
||||
url:
|
||||
http.devUrl +
|
||||
"/api/v1/cooperation/gas/list/trade?cooId=" +
|
||||
uuid +
|
||||
"&page=" +
|
||||
page +
|
||||
"&startTime=" +
|
||||
that.data.start +
|
||||
"&endTime=" +
|
||||
that.data.end,
|
||||
header: {
|
||||
"content-type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
success: (res) => {
|
||||
var items = that.data.items
|
||||
console.log(items, 'items');
|
||||
let temp = res.data.data.data.records;
|
||||
// if (page == 1) {
|
||||
// for (var i = 0; i < temp.length; i++) {
|
||||
// if (this.data.settlementType === 2) {
|
||||
// temp[i].payGift = (temp[i].money - temp[i].gasReceipts).toFixed(2)
|
||||
// }
|
||||
// }
|
||||
// wx.stopPullDownRefresh();
|
||||
// } else {
|
||||
// for (var i = 0; i < temp.length; i++) {
|
||||
// // temp[i].created = timeStr(temp[i].created, "YYYY-MM-DD hh:mm:ss");
|
||||
// if (this.data.settlementType === 2) {
|
||||
// temp[i].payGift = (temp[i].money - temp[i].gasReceipts).toFixed(2)
|
||||
// }
|
||||
// }
|
||||
|
||||
// }
|
||||
let newData = this.data.items;
|
||||
newData = offset ? newData.concat(temp) : temp;
|
||||
const settlementType = res.data.map.cooperation.settlementType
|
||||
if (settlementType === 2) {
|
||||
newData.forEach(item => {
|
||||
item.payGift = (item.money - item.gasReceipts).toFixed(2)
|
||||
})
|
||||
}
|
||||
var cooPrice = res.data.map.cooperation.cooPrice;
|
||||
if (cooPrice == null) {
|
||||
cooPrice = "--";
|
||||
}
|
||||
if (newData.length > 0) {
|
||||
this.setData({
|
||||
showList: true,
|
||||
}); ''
|
||||
console.log(temp, 'temptemptemptemp');
|
||||
loadMoreView.loadMoreComplete(temp);
|
||||
} else {
|
||||
this.setData({
|
||||
showList: false,
|
||||
});
|
||||
}
|
||||
wx.hideNavigationBarLoading();
|
||||
wx.hideLoading();
|
||||
if (offset === 0) {
|
||||
wx.stopPullDownRefresh();
|
||||
}
|
||||
that.setData({
|
||||
items: newData,
|
||||
cooperation: res.data.map.cooperation,
|
||||
cooPrice: cooPrice,
|
||||
moneyTotal: res.data.map.cooperation.money || 0,
|
||||
gasReceiptsTotal: res.data.map.cooperation.gasReceipts || 0,
|
||||
offersMoneyTotal: res.data.map.cooperation.offersMoney || 0,
|
||||
oilQuantityTotal: res.data.map.cooperation.oilQuantity || 0,
|
||||
isTriggered: false,
|
||||
totalPages: res.data.data.data.total,
|
||||
});
|
||||
// loadMoreView.loadMoreComplete(temp);
|
||||
},
|
||||
fail: () => {
|
||||
if (page != 1) {
|
||||
loadMoreView.loadMoreFail();
|
||||
}
|
||||
},
|
||||
complete: () => {
|
||||
wx.hideNavigationBarLoading();
|
||||
wx.hideLoading();
|
||||
}
|
||||
});
|
||||
},
|
||||
loadMoreListener: function (e) {
|
||||
page += 1;
|
||||
this.loadData(page);
|
||||
},
|
||||
clickLoadMore: function (e) {
|
||||
this.loadData(page);
|
||||
},
|
||||
updatePrice: function () {
|
||||
wx.navigateTo({
|
||||
url: "../updatePrice/updatePrice",
|
||||
});
|
||||
},
|
||||
});
|
||||
14
pages/oilManage/oilManage.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"navigationBarBackgroundColor": "#ffffff",
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "经营记录",
|
||||
"backgroundColor": "#fff",
|
||||
"backgroundTextStyle": "light",
|
||||
"navigationStyle": "default",
|
||||
"enablePullDownRefresh": true,
|
||||
"usingComponents": {
|
||||
"load-more": "../../components/load-more/index",
|
||||
"pay-list": "../../components/pay-list/pay-list",
|
||||
"datetime-picker": "../../components/datetimePicker/datetimePicker"
|
||||
}
|
||||
}
|
||||
113
pages/oilManage/oilManage.wxml
Normal file
@@ -0,0 +1,113 @@
|
||||
<view class="header">
|
||||
<view class="titleBox">
|
||||
<view class="title">{{stationName}}</view>
|
||||
<view class="amount">
|
||||
<view class="detail">
|
||||
<view class="number">{{settlementType===1?moneyTotal:gasReceiptsTotal}}</view>
|
||||
<view class="desc">{{settlementType===1?'应收金额 (元)':'实收金额(元)'}}</view>
|
||||
</view>
|
||||
<view class="detail" wx:if="{{settlementType===2}}">
|
||||
<view class="number">{{oilQuantityTotal}}</view>
|
||||
<view class="desc">加油量(公斤/升)</view>
|
||||
</view>
|
||||
</view>
|
||||
<image src="{{picImg}}new_bg.png" class="bg"></image>
|
||||
</view>
|
||||
<view class="priceBox">
|
||||
<view class="cooPriceBox">
|
||||
<view class="cooPrice">
|
||||
<view class="desc">挂牌价</view>
|
||||
<view class="num">¥{{cooPrice||'--'}}</view>
|
||||
</view>
|
||||
<view class="cooPrice" wx:if="{{settlementType===2}}">
|
||||
<view class="desc">站点优惠价</view>
|
||||
<view class="num">¥{{offersMoneyTotal||'--'}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="edit" wx:if="{{userType===0}}" data-type='{{settlementType}}' bind:tap='editPriceHandle'>
|
||||
<image src="../images/edit.png"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="main">
|
||||
<view class="mainHeader">
|
||||
<view class="desc">账单明细</view>
|
||||
<view class="search" bind:tap="showDateTimePick">
|
||||
<view>{{startView}}
|
||||
<text>至</text>
|
||||
</view>
|
||||
<view>{{endView}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<scroll-view scroll-y="true" class="scroll" bindscrolltolower="handleScrollToLower" refresher-enabled="true" refresher-triggered="{{isTriggered}}" bindrefresherrefresh="handleRefresherRefresh">
|
||||
<block hidden="{{!showList}}">
|
||||
<block wx:for="{{items}}" wx:key="index">
|
||||
<pay-list item="{{item}}" settlementType="{{settlementType}}"></pay-list>
|
||||
</block>
|
||||
<load-more id="loadMoreView" bindloadMoreListener='loadMoreListener' bindclickLoadMore='clickLoadMore'></load-more>
|
||||
</block>
|
||||
<block wx:if="{{!showList}}">
|
||||
<view class="emptyData">
|
||||
<image class="emptyDataImg" src="{{picImg+'emptyData.png'}}" mode="aspectFill" />
|
||||
<view class="emptyDataText">暂时还没有内容~</view>
|
||||
</view>
|
||||
</block>
|
||||
</scroll-view>
|
||||
</view>
|
||||
<view wx:if="{{userType !== 3}}">
|
||||
<image src="{{picImg}}ic_home_scan.png" mode="widthFix" class="scan" bindtap="showModal"></image>
|
||||
</view>
|
||||
<datetime-picker is_show='{{showDateTimePick}}' bind:setPickerTime="setPickerTime" config="{{pickerConfig}}"></datetime-picker>
|
||||
|
||||
<!-- 修改油价 -->
|
||||
<view class="input-body" wx:if="{{showOilModal}}" catchtouchmove="">
|
||||
<view class="input-modal">
|
||||
<view class="modal-headr">修改单价</view>
|
||||
<!-- 价格战 -->
|
||||
<view class="editInput">
|
||||
<view class="price">
|
||||
<text class="desc">挂牌价</text>
|
||||
<input class="oilInput" type="digit" value="{{price}}" confirm-type="done" placeholder="请输入挂牌价" maxlength="8" focus bindinput="setPrice"></input>
|
||||
</view>
|
||||
<view class='unit'><text>元</text></view>
|
||||
</view>
|
||||
<!-- 公斤站 -->
|
||||
<view class="editInput" wx:if="{{settlementType===2}}">
|
||||
<view class="price">
|
||||
<text class="desc">优惠价</text>
|
||||
<input class="oilInput" type="digit" value="{{offersMoney}}" confirm-type="done" placeholder="请输入站点优惠价" maxlength="8" focus bindinput="setOffersMoney"></input>
|
||||
</view>
|
||||
<view class='unit'><text>元</text></view>
|
||||
</view>
|
||||
<view class="modal-footer oil-footer">
|
||||
<view class="modal-footer-btn" bindtap="closeModal">取消</view>
|
||||
<view class="modal-footer-btn" bindtap="editOil" style="color:#367DF9;">确定</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 扫码核销 -->
|
||||
<view class="input-body" wx:if="{{showInputModal}}" catchtouchmove="">
|
||||
<view class="input-modal">
|
||||
<view class="modal-headr">扫码核销</view>
|
||||
<view class="editInput" wx:if='{{settlementType===1}}'>
|
||||
<view class="price">
|
||||
<text class="desc" style="width: 150rpx;">加油金额</text>
|
||||
<input class="oilInput" type="digit" value="{{money}}" confirm-type="done" placeholder="请输入油款金额" maxlength="8" focus bindinput="setMoney"></input>
|
||||
</view>
|
||||
<text class="unit">元</text>
|
||||
</view>
|
||||
|
||||
<view class="editInput" wx:if='{{settlementType===2}}'>
|
||||
<view class="price">
|
||||
<text class="desc">加油量</text>
|
||||
<input class="oilInput" type="digit" value="{{oilQuantity}}" confirm-type="done" placeholder="请输入加油量" maxlength="8" focus bindinput="setOilQuantity"></input>
|
||||
</view>
|
||||
|
||||
<text class="unit" style="width: 92rpx;">公斤/升</text>
|
||||
</view>
|
||||
<view class="modal-footer">
|
||||
<view class="modal-footer-btn" bindtap="hiddenModal">取消</view>
|
||||
<view class="modal-footer-btn" bindtap="getMoney" style="color:#367DF9;">确定</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
331
pages/oilManage/oilManage.wxss
Normal file
@@ -0,0 +1,331 @@
|
||||
.header {
|
||||
width: 100%;
|
||||
padding: 16rpx 34rpx 0;
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
height: 400rpx;
|
||||
}
|
||||
|
||||
.bg {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 302rpx;
|
||||
left: 0;
|
||||
top: 0;
|
||||
z-index: -99;
|
||||
}
|
||||
|
||||
.amount {
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.priceBox {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 34rpx;
|
||||
height: 120rpx;
|
||||
width: 682rpx;
|
||||
box-sizing: border-box;
|
||||
background: #F3F5F7;
|
||||
border-radius: 16rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 24rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.titleBox {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 302rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.title {
|
||||
padding-left: 24rpx;
|
||||
padding-top: 24rpx;
|
||||
color: #ffffff;
|
||||
font-size: 36rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.amount {
|
||||
display: flex;
|
||||
justify-content: space-evenly;
|
||||
flex: 1;
|
||||
align-content: center;
|
||||
}
|
||||
|
||||
|
||||
.amount .detail {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.detail .number {
|
||||
color: #ffffff;
|
||||
text-align: center;
|
||||
font-size: 48rpx;
|
||||
letter-spacing: 1rpx;
|
||||
}
|
||||
|
||||
.detail .desc {
|
||||
margin-top: 8rpx;
|
||||
color: #ffffff;
|
||||
text-align: center;
|
||||
font-size: 32rpx;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.cooPriceBox {
|
||||
margin-top: 46rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
align-items: center;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.cooPrice {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
}
|
||||
|
||||
.cooPrice .desc {
|
||||
color: #808080;
|
||||
text-align: center;
|
||||
font-size: 28rpx;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.cooPrice .num {
|
||||
margin-left: 8rpx;
|
||||
display: flex;
|
||||
color: #367df9;
|
||||
text-align: center;
|
||||
font-size: 36rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.edit image {
|
||||
margin-top: 46rpx;
|
||||
margin-left: 72rpx;
|
||||
display: block;
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.main {
|
||||
/* margin-top: 24rpx; */
|
||||
padding: 0 34rpx;
|
||||
height: calc(100% - 400rpx);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.scroll {
|
||||
height: calc(100% - 110rpx);
|
||||
}
|
||||
|
||||
.mainHeader {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
height: 106rpx;
|
||||
padding-top: 24rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.mainHeader .desc {
|
||||
color: #393939;
|
||||
text-align: center;
|
||||
font-size: 36rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.search {
|
||||
position: relative;
|
||||
color: #808080;
|
||||
font-size: 24rpx;
|
||||
font-weight: 500;
|
||||
margin-right: 32rpx;
|
||||
}
|
||||
|
||||
.search::after {
|
||||
position: absolute;
|
||||
content: '';
|
||||
right: -30rpx;
|
||||
top: 50%;
|
||||
width: 0px;
|
||||
height: 0px;
|
||||
border-left: 12rpx solid transparent;
|
||||
border-right: 12rpx solid transparent;
|
||||
border-top: 12rpx solid #808080;
|
||||
}
|
||||
|
||||
.emptyData {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 250px;
|
||||
}
|
||||
|
||||
.emptyData image {
|
||||
display: block;
|
||||
width: 166px;
|
||||
height: 194px;
|
||||
}
|
||||
|
||||
.emptyDataText {
|
||||
margin-top: 24px;
|
||||
color: #898989ff;
|
||||
font-size: 13px;
|
||||
font-weight: 400;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.input-body {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.input-body .input-modal {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
border-radius: 16rpx;
|
||||
width: 540rpx;
|
||||
transform: translate(-50%, -50%);
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.input-body .input-modal .modal-headr {
|
||||
padding: 32rpx 0 16rpx;
|
||||
text-align: center;
|
||||
color: #434343;
|
||||
height: 64rpx;
|
||||
color: #363636;
|
||||
text-align: center;
|
||||
font-size: 32rpx;
|
||||
font-weight: 700;
|
||||
line-height: 44rpx;
|
||||
}
|
||||
|
||||
.input-body .input-modal .modal-body {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
margin: 50rpx 20rpx;
|
||||
padding: 0 20rpx;
|
||||
}
|
||||
|
||||
|
||||
.input-modal .modal-footer {
|
||||
position: relative;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.modal-footer::after {
|
||||
position: absolute;
|
||||
content: '';
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
width: 2rpx;
|
||||
height: 50%;
|
||||
background: #F3F5F7;
|
||||
transform: translateY(-50%)
|
||||
}
|
||||
|
||||
.input-modal .modal-footer>view {
|
||||
flex-grow: 1;
|
||||
height: 90rpx;
|
||||
box-sizing: border-box;
|
||||
text-align: center;
|
||||
line-height: 90rpx;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
.oil-footer {
|
||||
font-size: 32rpx;
|
||||
}
|
||||
|
||||
.editInput {
|
||||
display: flex;
|
||||
font-size: 30rpx;
|
||||
justify-content: space-between;
|
||||
height: 68rpx;
|
||||
padding: 0 16rpx;
|
||||
align-items: center;
|
||||
border-radius: 8rpx;
|
||||
background: #F5F8FE;
|
||||
margin-left: 24rpx;
|
||||
margin-right: 42rpx;
|
||||
box-sizing: border-box;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.oilInput {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.price {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.price .desc {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 112rpx;
|
||||
color: #363636;
|
||||
font-size: 28rpx;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.price .desc::after {
|
||||
position: absolute;
|
||||
right: 16rpx;
|
||||
top: 50%;
|
||||
content: '';
|
||||
width: 2rpx;
|
||||
height: 50%;
|
||||
background: #8A8E9B;
|
||||
transform: translateY(-50%)
|
||||
}
|
||||
|
||||
.unit {
|
||||
width: 40rpx;
|
||||
top: 14rpx;
|
||||
color: #191b27;
|
||||
font-size: 26rpx;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.modify {
|
||||
color: #f3c010;
|
||||
border: 1rpx solid #f3c010;
|
||||
margin-left: 10rpx;
|
||||
border-radius: 10rpx;
|
||||
padding: 0 8rpx;
|
||||
}
|
||||
.scan{
|
||||
position: fixed;
|
||||
bottom: 120rpx;
|
||||
right: 72rpx;
|
||||
width: 104rpx;
|
||||
height: 104rpx;
|
||||
}
|
||||
137
pages/oilManage/oilManage2.wxml
Normal file
@@ -0,0 +1,137 @@
|
||||
<!-- <nav-bar navbar-data='{{nvabarData}}'></nav-bar> -->
|
||||
<view class='home-page'>
|
||||
<view class='view-root'>
|
||||
<!-- 钱包 -->
|
||||
<view class='tops' style="padding-top: {{height + 10}}px">
|
||||
<image mode="scaleToFill" class="tops-bg" style="width: 100vw;" src="http://static.sxlyb.com/images/bg1.gif"></image>
|
||||
<view class="tops-count" style="top: {{height + 10}}px">
|
||||
<view class="main-title">{{stationName}}</view>
|
||||
<!-- 价格战 -->
|
||||
<view class="kiloStation" wx:if="{{settlementType===1}}">
|
||||
<view class="priceHeader">
|
||||
<view class="cooPrice">
|
||||
<text class='cooPriceItem'>挂牌价:</text>
|
||||
<text class='cooPriceTotal'>¥{{cooPrice||'--'}}</text>
|
||||
</view>
|
||||
<view class="editPrice" wx:if="{{userType===0}}" data-type='{{settlementType}}' bind:tap='editPriceHandle'>
|
||||
修改
|
||||
</view>
|
||||
</view>
|
||||
<view class='pricefooter'>
|
||||
<view class="pricefooterItem">
|
||||
<view class="moneyTitle">应收金额(元)</view>
|
||||
<view class="moneyText">{{moneyTotal}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 公斤站 -->
|
||||
<view class='priceStation' wx:if="{{settlementType===2}}">
|
||||
<view class="priceHeader">
|
||||
<view class="cooPrice">
|
||||
<text class='cooPriceItem'>挂牌价:</text>
|
||||
<text class='cooPriceTotal'>¥{{cooPrice}}</text>
|
||||
</view>
|
||||
<view class="offersMoney">
|
||||
<text class='offersMoneyItem'>站点优惠价:</text>
|
||||
<text class='offersMoneyTotal'>¥{{offersMoneyTotal}}</text>
|
||||
</view>
|
||||
<view class='editPriceUserType' wx:if="{{userType===0}}" data-type='{{settlementType}}' bind:tap='editPriceHandle'>
|
||||
修改
|
||||
</view>
|
||||
</view>
|
||||
<view class='pricefooter'>
|
||||
<view class="pricefooterItem">
|
||||
<view class="moneyTitle">实收金额(元)</view>
|
||||
<view class="moneyText">{{gasReceiptsTotal}}</view>
|
||||
</view>
|
||||
<view class="pricefooterItem">
|
||||
<view class="moneyTitle">加油量(公斤/升)</view>
|
||||
<view class="moneyText">{{oilQuantityTotal}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 个人主页 -->
|
||||
<image mode="widthFix" class="seting" style="top: {{height+4}}px" src="../images/seting.png" bindtap="seting"></image>
|
||||
<!-- 扫码收费 -->
|
||||
<image mode="widthFix" src="http://static.sxlyb.com/images/sys01.png" bindtap="showModal" class="sao"></image>
|
||||
</view>
|
||||
<view class='t-money row'>
|
||||
<view class="flex-left">
|
||||
<view>
|
||||
<DatetimePicker mode="datetime" value="{{timeDivision}}" bindchange="selectStartChange">
|
||||
<view class="show-date-time-box">{{start}}</view>
|
||||
</DatetimePicker>
|
||||
</view>
|
||||
<view class="show-date-time-box flex-center">至</view>
|
||||
<view>
|
||||
<DatetimePicker mode="datetime" value="{{timeDivision}}" bindchange="selectEndChange">
|
||||
<view class="show-date-time-box">{{end}}</view>
|
||||
</DatetimePicker>
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex-right search" bind:tap="seatchHandle">筛选</view>
|
||||
</view>
|
||||
<!-- 交易记录列表 -->
|
||||
<view class="payList" wx:for="{{items}}" wx:key="index" style="width:100%" data-id="{{item.id}}">
|
||||
<view class="payTop">
|
||||
<view class="payPhone">{{item.description}}</view>
|
||||
<view class="payTime">{{item.created}}</view>
|
||||
</view>
|
||||
<view class="payBottom">
|
||||
<view class="payTotal" wx:if='{{settlementType===1}}'>
|
||||
<view class="payCenter">优惠{{item.payGift||0}}元</view>
|
||||
<view class="payCenter">实收{{item.actual||0}}元</view>
|
||||
</view>
|
||||
<view class="payTotal" wx:if='{{settlementType===2}}'>
|
||||
<view class="payLeft">{{item.oilQuantity||0}}公斤/升</view>
|
||||
<view class="payCenter">应收{{item.money||0}}元</view>
|
||||
<view class="payright">优惠{{item.payGift||0}}元</view>
|
||||
</view>
|
||||
<view class="payMoney" wx:if='{{settlementType===1}}'>+{{item.money}}</view>
|
||||
<view class="payMoney" wx:if='{{settlementType===2}}'>+{{item.gasReceipts}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<load-more id="loadMoreView" bindloadMoreListener='loadMoreListener' bindclickLoadMore='clickLoadMore'></load-more>
|
||||
<!-- <include src="../../components/picker_datetime.wxml"/> -->
|
||||
</view>
|
||||
<!-- 修改油价 -->
|
||||
<view class="input-body" wx:if="{{showOilModal}}" catchtouchmove="">
|
||||
<view class="input-modal">
|
||||
<view class="modal-headr">修改单价</view>
|
||||
<!-- 价格战 -->
|
||||
<view class="modal-body col flex-between editInput">
|
||||
<text>挂牌价</text>
|
||||
<input class="oilInput" type="digit" value="{{price}}" confirm-type="done" placeholder="请输入挂牌价" maxlength="8" focus bindinput="setPrice"></input>
|
||||
</view>
|
||||
<!-- 公斤站 -->
|
||||
<view class="modal-body col flex-between editInput" wx:if="{{settlementType===2}}">
|
||||
<text>站点优惠价</text>
|
||||
<input class="oilInput" type="digit" value="{{offersMoney}}" confirm-type="done" placeholder="请输入站点优惠价" maxlength="8" focus bindinput="setOffersMoney"></input>
|
||||
</view>
|
||||
<view class="modal-footer oil-footer">
|
||||
<view class="modal-footer-btn" bindtap="closeModal">取消</view>
|
||||
<view class="modal-footer-btn" bindtap="editOil" style="color:#07c160;">确定</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="input-body" wx:if="{{showInputModal}}" catchtouchmove="">
|
||||
<view class="input-modal">
|
||||
<view class="modal-headr">扫码核销</view>
|
||||
<view class="modal-body" wx:if='{{settlementType===1}}'>
|
||||
<text class="checkMoney">加油金额</text>
|
||||
<input type="digit" value="{{money}}" confirm-type="done" placeholder="请输入油款金额" maxlength="8" focus bindinput="setMoney"></input>
|
||||
<text class="moneyUnit">元</text>
|
||||
</view>
|
||||
<view class="modal-body" wx:if='{{settlementType===2}}'>
|
||||
<text class="checkMoney">加油量</text>
|
||||
<input type="digit" value="{{oilQuantity}}" confirm-type="done" placeholder="请输入加油量" maxlength="8" focus bindinput="setOilQuantity"></input>
|
||||
<text class="moneyUnit">公斤/升</text>
|
||||
</view>
|
||||
<view class="modal-footer">
|
||||
<view class="modal-footer-btn" bindtap="hiddenModal">取消</view>
|
||||
<view class="modal-footer-btn" bindtap="getMoney" style="color:#07c160;">确定</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
15
pages/openapi/callback/callback.js
Normal file
@@ -0,0 +1,15 @@
|
||||
// miniprogram/pages/openapi/callback/callback.js
|
||||
Page({
|
||||
|
||||
data: {
|
||||
|
||||
},
|
||||
|
||||
onLoad: function (options) {
|
||||
|
||||
},
|
||||
|
||||
onCustomerServiceButtonClick(e) {
|
||||
console.log(e)
|
||||
},
|
||||
})
|
||||
3
pages/openapi/callback/callback.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
||||
16
pages/openapi/callback/callback.wxml
Normal file
@@ -0,0 +1,16 @@
|
||||
<view class="container">
|
||||
<view class="list">
|
||||
<button open-type="contact" bindcontact="onCustomerServiceButtonClick">
|
||||
进入客服消息
|
||||
</button>
|
||||
</view>
|
||||
|
||||
<view class="guide">
|
||||
<text class="headline">测试须知</text>
|
||||
<text class="p">1. 进入云开发控制台“设置-全局设置”,选择添加消息推送配置</text>
|
||||
<text class="p">2. 消息类型选择 text(文本客户消息)</text>
|
||||
<text class="p">3. 事件类型选择空</text>
|
||||
<text class="p">4. 选择需要推送到哪个环境的哪个云函数</text>
|
||||
<text class="p">5. 在手机上测试</text>
|
||||
</view>
|
||||
</view>
|
||||
3
pages/openapi/callback/callback.wxss
Normal file
@@ -0,0 +1,3 @@
|
||||
/* miniprogram/pages/openapi/callback/callback.wxss */
|
||||
|
||||
@import "../../../style/guide.wxss";
|
||||
60
pages/openapi/cloudid/cloudid.js
Normal file
@@ -0,0 +1,60 @@
|
||||
// miniprogram/pages/openapi/cloudid/cloudid.js
|
||||
Page({
|
||||
|
||||
data: {
|
||||
weRunResult: '',
|
||||
userInfoResult: '',
|
||||
},
|
||||
|
||||
onGetWeRunData() {
|
||||
wx.getWeRunData({
|
||||
success: res => {
|
||||
wx.cloud.callFunction({
|
||||
name: 'echo',
|
||||
data: {
|
||||
// info 字段在云函数 event 对象中会被自动替换为相应的敏感数据
|
||||
info: wx.cloud.CloudID(res.cloudID),
|
||||
},
|
||||
}).then(res => {
|
||||
console.log('[onGetWeRunData] 收到 echo 回包:', res)
|
||||
|
||||
this.setData({
|
||||
weRunResult: JSON.stringify(res.result),
|
||||
})
|
||||
|
||||
wx.showToast({
|
||||
title: '敏感数据获取成功',
|
||||
})
|
||||
}).catch(err => {
|
||||
console.log('[onGetWeRunData] 失败:', err)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
|
||||
onGetUserInfo(e) {
|
||||
console.log(e)
|
||||
wx.cloud.callFunction({
|
||||
name: 'openapi',
|
||||
data: {
|
||||
action: 'getOpenData',
|
||||
openData: {
|
||||
list: [
|
||||
e.detail.cloudID,
|
||||
]
|
||||
}
|
||||
}
|
||||
}).then(res => {
|
||||
console.log('[onGetUserInfo] 调用成功:', res)
|
||||
|
||||
this.setData({
|
||||
userInfoResult: JSON.stringify(res.result),
|
||||
})
|
||||
|
||||
wx.showToast({
|
||||
title: '敏感数据获取成功',
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
3
pages/openapi/cloudid/cloudid.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
||||
41
pages/openapi/cloudid/cloudid.wxml
Normal file
@@ -0,0 +1,41 @@
|
||||
<!--index.wxml-->
|
||||
<view class="container">
|
||||
|
||||
<view class="guide">
|
||||
<text class="headline">开放数据调用</text>
|
||||
<text class="p">通过 cloudID 获取敏感开放数据有以下两种方式</text>
|
||||
<text class="p">1. 小程序端 callFunction 自动获取</text>
|
||||
<text class="p">2. 通过 wx-server-sdk 获取</text>
|
||||
<text class="p">以下分别先后展示这两种获取方式</text>
|
||||
</view>
|
||||
|
||||
<view class="uploader">
|
||||
<button class="uploader-text" bindtap="onGetWeRunData">getWeRunData 敏感数据获取</button>
|
||||
</view>
|
||||
|
||||
<view class="guide">
|
||||
<text class="headline">测试须知</text>
|
||||
<text class="p">1. 公共库版本需大于 2.7.0</text>
|
||||
<text class="p">2. 请确保 echo 函数已上传</text>
|
||||
</view>
|
||||
|
||||
<view class="guide" style="word-break: break-all">
|
||||
{{weRunResult}}
|
||||
</view>
|
||||
|
||||
|
||||
<view class="uploader">
|
||||
<button class="uploader-text" open-type="getUserInfo" bindgetuserinfo="onGetUserInfo">getUserInfo 敏感数据获取</button>
|
||||
</view>
|
||||
|
||||
<view class="guide">
|
||||
<text class="headline">测试须知</text>
|
||||
<text class="p">1. 公共库版本需大于 2.7.0</text>
|
||||
<text class="p">2. 请确保 openapi 函数已上传</text>
|
||||
</view>
|
||||
|
||||
<view class="guide" style="word-break: break-all">
|
||||
{{userInfoResult}}
|
||||
</view>
|
||||
|
||||
</view>
|
||||
1
pages/openapi/cloudid/cloudid.wxss
Normal file
@@ -0,0 +1 @@
|
||||
@import "../../../style/guide.wxss";
|
||||
109
pages/openapi/openapi.js
Normal file
@@ -0,0 +1,109 @@
|
||||
Page({
|
||||
|
||||
data: {
|
||||
templateMessageResult: '',
|
||||
wxacodeSrc: '',
|
||||
wxacodeResult: '',
|
||||
showClearWXACodeCache: false,
|
||||
},
|
||||
|
||||
submitTemplateMessageForm(e) {
|
||||
this.setData({
|
||||
templateMessageResult: '',
|
||||
})
|
||||
|
||||
wx.cloud.callFunction({
|
||||
name: 'openapi',
|
||||
data: {
|
||||
action: 'sendTemplateMessage',
|
||||
formId: e.detail.formId,
|
||||
},
|
||||
success: res => {
|
||||
console.warn('[云函数] [openapi] templateMessage.send 调用成功:', res)
|
||||
wx.showModal({
|
||||
title: '发送成功',
|
||||
content: '请返回微信主界面查看',
|
||||
showCancel: false,
|
||||
})
|
||||
wx.showToast({
|
||||
title: '发送成功,请返回微信主界面查看',
|
||||
})
|
||||
this.setData({
|
||||
templateMessageResult: JSON.stringify(res.result)
|
||||
})
|
||||
},
|
||||
fail: err => {
|
||||
wx.showToast({
|
||||
icon: 'none',
|
||||
title: '调用失败',
|
||||
})
|
||||
console.error('[云函数] [openapi] templateMessage.send 调用失败:', err)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
onGetWXACode() {
|
||||
|
||||
this.setData({
|
||||
wxacodeSrc: '',
|
||||
wxacodeResult: '',
|
||||
showClearWXACodeCache: false,
|
||||
})
|
||||
|
||||
// 此处为演示,将使用 localStorage 缓存,正常开发中文件 ID 应存在数据库中
|
||||
const fileID = wx.getStorageSync('wxacodeCloudID')
|
||||
|
||||
if (fileID) {
|
||||
// 有云文件 ID 缓存,直接使用该 ID
|
||||
// 如需清除缓存,选择菜单栏中的 “工具 -> 清除缓存 -> 清除数据缓存”,或在 Storage 面板中删掉相应的 key
|
||||
this.setData({
|
||||
wxacodeSrc: fileID,
|
||||
wxacodeResult: `从本地缓存中取得了小程序码的云文件 ID`,
|
||||
showClearWXACodeCache: true,
|
||||
})
|
||||
console.log(`从本地缓存中取得了小程序码的云文件 ID:${fileID}`)
|
||||
} else {
|
||||
wx.cloud.callFunction({
|
||||
name: 'openapi',
|
||||
data: {
|
||||
action: 'getWXACode',
|
||||
},
|
||||
success: res => {
|
||||
console.warn('[云函数] [openapi] wxacode.get 调用成功:', res)
|
||||
wx.showToast({
|
||||
title: '调用成功',
|
||||
})
|
||||
this.setData({
|
||||
wxacodeSrc: res.result,
|
||||
wxacodeResult: `云函数获取二维码成功`,
|
||||
showClearWXACodeCache: true,
|
||||
})
|
||||
wx.setStorageSync('wxacodeCloudID', res.result)
|
||||
},
|
||||
fail: err => {
|
||||
wx.showToast({
|
||||
icon: 'none',
|
||||
title: '调用失败',
|
||||
})
|
||||
console.error('[云函数] [openapi] wxacode.get 调用失败:', err)
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
clearWXACodeCache() {
|
||||
wx.removeStorageSync('wxacodeCloudID')
|
||||
|
||||
this.setData({
|
||||
wxacodeSrc: '',
|
||||
wxacodeResult: '',
|
||||
showClearWXACodeCache: false,
|
||||
})
|
||||
|
||||
wx.showToast({
|
||||
title: '清除成功',
|
||||
})
|
||||
},
|
||||
|
||||
})
|
||||
|
||||
3
pages/openapi/openapi.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
||||