推拿小程序前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

356 lines
7.8 KiB

3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
  1. <template>
  2. <view class="page">
  3. <!-- 导航栏 -->
  4. <navbar title="提现" leftClick @leftClick="$utils.navigateBack" color="#fff" />
  5. <view class="content">
  6. <!-- 佣金信息 -->
  7. <view class="info">
  8. <image class="info-bg" src="../static/withdraw/bg.png"></image>
  9. <view class="info-content">
  10. <view class="label">佣金</view>
  11. <view class="value">{{ userInfo.recommendAmount || 0 }}</view>
  12. <view class="flex desc">
  13. <!-- todo: 对接接口字段 -->
  14. <view>{{ `累积提现:${userInfo.cashoutSum || 0}` }}</view>
  15. <button plain class="btn" @click="toRunningWater">
  16. <text>提现记录</text>
  17. <image class="btn-icon" src="@/static/image/center/icon-arrow.png" mode="widthFix"></image>
  18. </button>
  19. </view>
  20. </view>
  21. </view>
  22. <!-- 我要提现 -->
  23. <view class="form">
  24. <view class="form-title">我要提现</view>
  25. <view class="form-item">
  26. <uv-input
  27. v-model.number="form.money"
  28. placeholder="请输入提现金额"
  29. :placeholderStyle="placeholderStyle"
  30. :customStyle="customStyle"
  31. color="#FF2A2A"
  32. >
  33. <template #prefix>
  34. <view class="unit"></view>
  35. </template>
  36. </uv-input>
  37. </view>
  38. <view class="form-item">
  39. <uv-input
  40. v-model.trim="form.name"
  41. placeholder="请输入真实姓名"
  42. :placeholderStyle="placeholderStyle"
  43. :customStyle="customStyle"
  44. ></uv-input>
  45. </view>
  46. </view>
  47. <!-- 提现说明 -->
  48. <view class="desc">
  49. <view class="desc-title">提现说明</view>
  50. <!-- todo: check -->
  51. <uv-parse class="desc-content" :content="configList.recharge_instructions"></uv-parse>
  52. <!-- <view v-html="configList.recharge_instructions" class="withdrawal-statement" style="color: #666666;"></view> -->
  53. </view>
  54. <view class="tools">
  55. <button class="flex btn" @click="withdraw">立即提现</button>
  56. </view>
  57. </view>
  58. </view>
  59. </template>
  60. <script>
  61. import mixinsList from '@/mixins/list.js'
  62. import {
  63. mapState
  64. } from 'vuex'
  65. export default {
  66. mixins: [mixinsList],
  67. computed: {
  68. ...mapState(['userInfo', 'riceInfo']),
  69. },
  70. data() {
  71. return {
  72. form: {
  73. money: '',
  74. name: '',
  75. },
  76. placeholderStyle: {
  77. color: '#999999',
  78. fontSize: '28rpx',
  79. },
  80. customStyle: {
  81. backgroundColor: '#F5F5F5',
  82. border: 'none',
  83. borderRadius: '16rpx',
  84. padding: '28rpx 35rpx'
  85. }
  86. }
  87. },
  88. onShow() {
  89. this.$store.commit('getUserInfo')
  90. this.$store.commit('getRiceInfo')
  91. },
  92. methods: {
  93. withdraw() { //立即提现
  94. if (!this.form.name) {
  95. uni.showToast({
  96. title: '请输入真实姓名',
  97. icon: 'none'
  98. })
  99. return
  100. }
  101. if (this.form.money < 1) {
  102. return uni.showToast({
  103. title: '提现只能是整数必须大于1!',
  104. icon: 'none'
  105. })
  106. }
  107. // todo
  108. // if (this.form.money < 300) {
  109. // return uni.showToast({
  110. // title: '未满300元不可提现哦!',
  111. // icon: 'none'
  112. // })
  113. // }
  114. let isOk = this.parameterVerification();
  115. if (isOk && !isOk.auth) {
  116. return uni.showToast({
  117. title: isOk.title,
  118. icon: 'none'
  119. })
  120. }
  121. // this.$api('recharge', this.form, res => {
  122. // if (res.code == 200) {
  123. // uni.showToast({
  124. // title: '提现成功',
  125. // icon: 'none'
  126. // })
  127. // this.$store.commit('getUserInfo')
  128. // this.$store.commit('getRiceInfo')
  129. // }
  130. // })
  131. // 显示提交中状态
  132. uni.showLoading({
  133. title: '提交中...'
  134. })
  135. // 提现
  136. this.$api('cashout', { transferAmount: this.form.money, userName: this.form.name }, res => {
  137. uni.hideLoading()
  138. if (res.code === 200) {
  139. // 处理待收款用户确认的情况
  140. if (res.result && res.result.state === 'WAIT_USER_CONFIRM' && res.result.packageInfo && res.result.outBillNo) {
  141. // 拉起微信收款确认页面
  142. if (!wx.canIUse('requestMerchantTransfer')) {
  143. wx.showModal({
  144. content: '你的微信版本过低,请更新至最新版本。',
  145. showCancel: false,
  146. });
  147. return
  148. }
  149. let data = res.result
  150. // 在真机环境中,调用API
  151. wx.requestMerchantTransfer({
  152. mchId: this.$config.mchId,
  153. appId: wx.getAccountInfoSync().miniProgram.appId,
  154. package: res.result.packageInfo,
  155. success: (res) => {
  156. uni.showToast({
  157. title: '提现申请已提交',
  158. icon: 'success'
  159. })
  160. this.form.money = ''
  161. this.form.name = ''
  162. this.$api('getMoney', {
  163. id : data.outBillNo,
  164. }).then(res => {
  165. this.$store.commit('getUserInfo')
  166. this.$store.commit('getRiceInfo')
  167. })
  168. },
  169. fail: (res) => {
  170. console.log('fail:', res);
  171. uni.showToast({
  172. title: '提现失败,请稍后再试',
  173. icon: 'none'
  174. })
  175. },
  176. complete: (res) => {
  177. console.log('requestMerchantTransfer完成:', res);
  178. }
  179. });
  180. } else {
  181. uni.showToast({
  182. title: '提现成功',
  183. icon: 'success'
  184. })
  185. this.$store.commit('getUserInfo')
  186. this.form.money = ''
  187. this.form.name = ''
  188. }
  189. }else{
  190. uni.showToast({
  191. title: res.message,
  192. icon: 'none'
  193. })
  194. }
  195. })
  196. },
  197. parameterVerification() { //验证用户参数合法性
  198. let {
  199. money
  200. } = this.form
  201. if (!money) {
  202. return {
  203. title: '请填写提现金额',
  204. auth: false
  205. }
  206. }
  207. return {
  208. title: '验证通过',
  209. auth: true
  210. }
  211. },
  212. toRunningWater() {
  213. uni.navigateTo({
  214. url: "/pages_order/mine/runningWater"
  215. })
  216. }
  217. }
  218. }
  219. </script>
  220. <style scoped lang="scss">
  221. .page {
  222. background-color: $uni-fg-color;
  223. min-height: 100vh;
  224. /deep/ .nav-bar__view {
  225. background-image: linear-gradient(#84A73F, #D8FF8F);
  226. }
  227. }
  228. .content {
  229. padding: 28rpx 13rpx;
  230. }
  231. .info {
  232. position: relative;
  233. width: 100%;
  234. height: 290rpx;
  235. &-bg {
  236. width: 100%;
  237. height: 100%;
  238. }
  239. &-content {
  240. position: absolute;
  241. top: 0;
  242. left: 0;
  243. width: 100%;
  244. box-sizing: border-box;
  245. padding: 42rpx 48rpx 0 35rpx;
  246. color: $uni-text-color-inverse;
  247. .label {
  248. font-size: 30rpx;
  249. }
  250. .value {
  251. margin-top: 18rpx;
  252. font-weight: 700;
  253. font-size: 55rpx;
  254. }
  255. .desc {
  256. justify-content: space-between;
  257. font-size: 22rpx;
  258. margin-top: 58rpx;
  259. }
  260. .btn {
  261. border: none;
  262. font-size: 22rpx;
  263. color: $uni-text-color-inverse;
  264. &-icon {
  265. width: 16rpx;
  266. height: 16rpx;
  267. margin-left: 7rpx;
  268. }
  269. }
  270. }
  271. }
  272. .form {
  273. margin-top: 30rpx;
  274. &-title {
  275. color: #000000;
  276. font-size: 28rpx;
  277. padding: 0 35rpx;
  278. }
  279. &-item {
  280. margin-top: 18rpx;
  281. .unit {
  282. color: #FF2A2A;
  283. padding-left: 42rpx;
  284. }
  285. }
  286. }
  287. .desc {
  288. margin-top: 45rpx;
  289. padding: 0 42rpx;
  290. font-size: 28rpx;
  291. &-title {
  292. color: #000000;
  293. }
  294. &-content {
  295. margin-top: 10rpx;
  296. color: #707070;
  297. }
  298. }
  299. .tools {
  300. margin-top: 166rpx;
  301. padding: 0 69rpx;
  302. .btn {
  303. width: 100%;
  304. padding: 29rpx 0;
  305. color: $uni-text-color-inverse;
  306. font-size: 28rpx;
  307. line-height: 40rpx;
  308. border-radius: 49rpx;
  309. border: none;
  310. background-image: linear-gradient(to right, #84A73F, #D8FF8F);
  311. }
  312. }
  313. </style>