推拿小程序前端代码仓库
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.

240 lines
5.5 KiB

4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
  1. <template>
  2. <view class="page">
  3. <!-- 导航栏 -->
  4. <navbar title="提现记录" leftClick @leftClick="$utils.navigateBack" color="#fff" />
  5. <view class="tools">
  6. <uv-datetime-picker ref="datetimePicker" v-model="selectedTime" mode="year-month" confirmColor="#84A73F"
  7. @confirm="onTimeChange"></uv-datetime-picker>
  8. <button plain class="flex btn" @click="openTimePicker">
  9. <text>{{ displaySelectedTime }}</text>
  10. <image class="btn-icon" src="../static/runningWater/icon-arrow.png" mode="widthFix"></image>
  11. </button>
  12. </view>
  13. <view class="card list">
  14. <template v-if="list.length">
  15. <view class="flex list-item" v-for="(item, index) in list" :key="index">
  16. <image class="list-item-icon" src="../static/runningWater/icon-commission.png" mode="widthFix">
  17. </image>
  18. <view class="list-item-info">
  19. <view class="highlight">佣金提现</view>
  20. <view>{{ item.createTime }}</view>
  21. </view>
  22. <view class="list-item-value">{{ `-${item.amount}` }}</view>
  23. <view class="uni-color-btn" @click="withdraw(item)" v-if="item.status == 0">领取</view>
  24. </view>
  25. </template>
  26. <template v-else>
  27. <uv-empty mode="history" textSize="28rpx" iconSize="100rpx" />
  28. </template>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import mixinsList from "@/mixins/list.js"
  34. export default {
  35. mixins: [mixinsList],
  36. data() {
  37. return {
  38. selectedTime: new Date(),
  39. x: ['+', '-', '-', '+'],
  40. mixinsListApi: "queryCashoutLog", //getWaterPageList
  41. beforeDate: new Date(), //开始日期
  42. afterDate: new Date(), //结束日期
  43. totalMoney: 0,
  44. totalWithdraw: 0,
  45. }
  46. },
  47. computed: {
  48. displaySelectedTime() {
  49. return this.$dayjs(this.selectedTime).format("YYYY年M月")
  50. }
  51. },
  52. methods: {
  53. //打开日历
  54. openCalendars() {
  55. if (this?.$refs?.calendars) {
  56. this.$refs.calendars.open();
  57. }
  58. },
  59. // 选择了日期
  60. handleSelectCalendars(day) {
  61. console.log(day);
  62. // let beforeDate = this.getYearMonth(day?.range?.before)
  63. // let afterDate = this.getYearMonth(day?.range?.after)
  64. // this.beforeYear = beforeDate.year;
  65. // this.beforeMonth = beforeDate.month;
  66. // this.afterYear = afterDate.year;
  67. // this.afterMonth = afterDate.month;
  68. },
  69. getDataThen(list, total, result) {
  70. this.totalMoney = result.totalMoney
  71. this.totalWithdraw = result.totalWithdraw
  72. this.list = result.page.records
  73. this.total = result.page.total
  74. },
  75. openTimePicker() {
  76. this.$refs.datetimePicker.open();
  77. },
  78. onTimeChange(e) {
  79. // todo
  80. console.log('--onTimeChange', e)
  81. },
  82. requestMerchantTransferH5(item, fn) {
  83. wx.ready(function() {
  84. wx.checkJsApi({
  85. jsApiList: ['requestMerchantTransfer'],
  86. success: function(res) {
  87. if (res.checkResult['requestMerchantTransfer']) {
  88. WeixinJSBridge.invoke('requestMerchantTransfer', {
  89. appId: this.$config.appId,
  90. mchId: this.$config.mchId,
  91. package: item.packageInfo,
  92. },
  93. function(res) {
  94. if (res.err_msg === 'requestMerchantTransfer:ok') {
  95. // res.err_msg将在页面展示成功后返回应用时返回success,并不代表付款成功
  96. fn && fn()
  97. }
  98. }
  99. );
  100. } else {
  101. alert('你的微信版本过低,请更新至最新版本。');
  102. }
  103. }
  104. });
  105. });
  106. },
  107. withdraw(item) {
  108. // #ifdef H5
  109. this.requestMerchantTransferH5(item, () => {
  110. this.$store.commit('getUserInfo')
  111. this.$store.commit('getRiceInfo')
  112. this.$api('getMoney', {
  113. id: item.id,
  114. }).then(res => {
  115. this.getData()
  116. })
  117. })
  118. return
  119. // #endif
  120. // 拉起微信收款确认页面
  121. if (!wx.canIUse('requestMerchantTransfer')) {
  122. wx.showModal({
  123. content: '你的微信版本过低,请更新至最新版本。',
  124. showCancel: false,
  125. });
  126. return
  127. }
  128. // 在真机环境中,调用API
  129. wx.requestMerchantTransfer({
  130. appId: wx.getAccountInfoSync().miniProgram.appId,
  131. mchId: this.$config.mchId,
  132. package: item.packageInfo,
  133. success: (res) => {
  134. this.$store.commit('getUserInfo')
  135. this.$store.commit('getRiceInfo')
  136. this.$api('getMoney', {
  137. id: item.id,
  138. }).then(res => {
  139. this.getData()
  140. })
  141. },
  142. fail: (res) => {
  143. console.log('fail:', res);
  144. uni.showToast({
  145. title: '提现失败,请稍后再试',
  146. icon: 'none'
  147. })
  148. },
  149. complete: (res) => {
  150. console.log('requestMerchantTransfer完成:', res);
  151. }
  152. });
  153. },
  154. }
  155. }
  156. </script>
  157. <style lang="scss" scoped>
  158. .page {
  159. background-color: $uni-bg-color;
  160. min-height: 100vh;
  161. /deep/ .nav-bar__view {
  162. background-image: linear-gradient(#84A73F, #D8FF8F);
  163. }
  164. }
  165. .uni-color-btn {
  166. padding: 10rpx 20rpx;
  167. margin: 0;
  168. font-size: 26rpx;
  169. margin-left: 20rpx;
  170. }
  171. .tools {
  172. background-color: $uni-fg-color;
  173. padding: 25rpx 42rpx;
  174. .btn {
  175. display: inline-block;
  176. border: none;
  177. color: #000000;
  178. font-size: 28rpx;
  179. line-height: 40rpx;
  180. &-icon {
  181. width: 28rpx;
  182. height: 28rpx;
  183. margin-left: 12rpx;
  184. }
  185. }
  186. }
  187. .list {
  188. margin: 9rpx 13rpx;
  189. padding: 31rpx 20rpx;
  190. &-item {
  191. padding-bottom: 19rpx;
  192. border-bottom: 1rpx solid #E0E0E0;
  193. margin-bottom: 20rpx;
  194. font-size: 28rpx;
  195. &-icon {
  196. width: 56rpx;
  197. height: auto;
  198. margin-right: 10rpx;
  199. }
  200. &-info {
  201. flex: 1;
  202. color: #949494;
  203. .highlight {
  204. color: #333333;
  205. }
  206. }
  207. &-value {
  208. color: #FF2A2A;
  209. }
  210. }
  211. }
  212. </style>