Skip to content

Commit 149f00f

Browse files
committed
add .gitignore
1 parent 4438a27 commit 149f00f

File tree

246 files changed

+1444
-50014
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

246 files changed

+1444
-50014
lines changed

components/.DS_Store

-6 KB
Binary file not shown.

pages/.DS_Store

-6 KB
Binary file not shown.

pages/asset/deposit.vue

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<template>
2+
<view>
3+
<view class="form-box">
4+
<u-form ref="uForm" label-width="130rpx" :model="form">
5+
<u-form-item label="可用余额">
6+
<u-text mode="price" :text="balance" align="right"></u-text>
7+
</u-form-item>
8+
<u-form-item label="支付金额" prop="amount" required>
9+
<u-input v-model="form.amount" type="digit" clearable placeholder="请输入押金金额"></u-input>
10+
</u-form-item>
11+
</u-form>
12+
</view>
13+
<view class="submit-btn">
14+
<u-button type="success" @click="submit">支付押金</u-button>
15+
</view>
16+
</view>
17+
</template>
18+
19+
<script>
20+
const PAY = require('@/common/pay.js')
21+
export default {
22+
data() {
23+
return {
24+
balance: 0.00,
25+
rules: {
26+
amount: [{
27+
required: true,
28+
type: 'number',
29+
message: '不能为空',
30+
// 可以单个或者同时写两个触发验证方式
31+
trigger: ['change', 'blur'],
32+
}],
33+
},
34+
form: {
35+
amount: null
36+
},
37+
}
38+
},
39+
created() {
40+
41+
},
42+
mounted() {
43+
44+
},
45+
onReady() {
46+
this.$refs.uForm.setRules(this.rules);
47+
},
48+
onLoad(e) {
49+
this._userAmount()
50+
},
51+
onShow() {
52+
53+
},
54+
methods: {
55+
async _userAmount() {
56+
// https://www.yuque.com/apifm/nu0f75/wrqkcb
57+
const res = await this.$wxapi.userAmount(this.token)
58+
if (res.code == 0) {
59+
this.balance = res.data.balance.toFixed(2)
60+
}
61+
},
62+
submit() {
63+
this.$refs.uForm.validate().then(res => {
64+
this._submit()
65+
}).catch(errors => {
66+
uni.showToast({
67+
title: '表单请填写完整',
68+
icon: 'none'
69+
})
70+
})
71+
},
72+
async _submit() {
73+
const onlinePayAmount = this.form.amount - this.balance
74+
if (onlinePayAmount <= 0) {
75+
// 使用余额支付押金 https://www.yuque.com/apifm/nu0f75/mpsdwi
76+
const res = await this.$wxapi.payDeposit({
77+
token: this.token,
78+
amount: this.form.amount
79+
})
80+
if (res.code != 0) {
81+
uni.showToast({
82+
title: res.msg,
83+
icon: 'none'
84+
})
85+
return
86+
}
87+
uni.showModal({
88+
showCancel:false,
89+
title: '成功',
90+
content: '支付成功',
91+
confirmText: '知道了',
92+
success: () => {
93+
uni.redirectTo({
94+
url: "/pages/asset/depositlog"
95+
})
96+
}
97+
})
98+
} else {
99+
// 在线支付押金 TODO
100+
PAY.pay('wxpay', {
101+
appid: getApp().globalData.wxpayOpenAppId
102+
}, onlinePayAmount.toFixed(2), '支付押金', '支付押金', {
103+
type: 5,
104+
amount: this.form.amount
105+
}, () => {
106+
uni.redirectTo({
107+
url: "/pages/asset/depositlog"
108+
})
109+
}, (err) => {
110+
uni.showToast({
111+
title: '支付失败',
112+
icon: 'none'
113+
})
114+
})
115+
}
116+
},
117+
}
118+
}
119+
</script>
120+
<style scoped lang="scss">
121+
.form-box {
122+
padding: 32rpx;
123+
}
124+
</style>

pages/asset/depositlog.vue

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<template>
2+
<view>
3+
<page-box-empty v-if="!depositLogs || depositLogs.length == 0" title="暂无押金记录" sub-title="可前往用户中心支付押金~" :show-btn="false" />
4+
<u-cell v-for="(item,index) in depositLogs" :key="index" :title="item.statusStr + ' ('+ item.number +')'" :label="item.dateAdd"
5+
:value="'¥' + item.amount" isLink :name="index" @click="depositBackApply"></u-cell>
6+
</view>
7+
</template>
8+
9+
<script>
10+
export default {
11+
data() {
12+
return {
13+
page: 1,
14+
depositLogs: undefined,
15+
}
16+
},
17+
created() {
18+
19+
},
20+
mounted() {
21+
22+
},
23+
onReady() {
24+
25+
},
26+
onLoad(e) {
27+
this._depositLogs()
28+
},
29+
onShow() {
30+
31+
},
32+
onReachBottom() {
33+
this.page++
34+
this._depositLogs()
35+
},
36+
onPullDownRefresh() {
37+
this.page = 1
38+
this._depositLogs()
39+
uni.stopPullDownRefresh()
40+
},
41+
methods: {
42+
async _depositLogs() {
43+
// https://www.yuque.com/apifm/nu0f75/xd6g5h
44+
const res = await this.$wxapi.depositList({
45+
token: this.token,
46+
page: this.page
47+
})
48+
if (res.code == 0) {
49+
if(this.page == 1) {
50+
this.depositLogs = res.data.result
51+
} else {
52+
this.depositLogs = this.depositLogs.concat(res.data.result)
53+
}
54+
} else {
55+
if(this.page > 1) {
56+
uni.showToast({
57+
title: '没有更多了'
58+
})
59+
}
60+
}
61+
},
62+
depositBackApply(e) {
63+
const item = this.depositLogs[e.name]
64+
if (item.status != 1) {
65+
return
66+
}
67+
uni.showModal({
68+
title: '请确认',
69+
content: '确认要申请退还押金?',
70+
success: res => {
71+
if (res.confirm) {
72+
this._depositBackApply(e.name)
73+
}
74+
}
75+
});
76+
},
77+
async _depositBackApply(index) {
78+
const item = this.depositLogs[index]
79+
const res = await this.$wxapi.depositBackApply(this.token, item.id)
80+
if (res.code != 0) {
81+
uni.showToast({
82+
title: '没有更多了',
83+
icon:"none"
84+
})
85+
return
86+
}
87+
uni.showModal({
88+
showCancel:false,
89+
title: '成功',
90+
content: '申请成功,请等待财务处理',
91+
confirmText: '知道了',
92+
success: () => {
93+
this.page = 1
94+
this._depositLogs()
95+
}
96+
})
97+
}
98+
}
99+
}
100+
</script>
101+
<style scoped lang="scss">
102+
103+
</style>

0 commit comments

Comments
 (0)