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

302 lines
6.9 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. onLoad() {
  53. },
  54. methods: {
  55. //打开日历
  56. openCalendars() {
  57. if (this?.$refs?.calendars) {
  58. this.$refs.calendars.open();
  59. }
  60. },
  61. // 选择了日期
  62. handleSelectCalendars(day) {
  63. console.log(day);
  64. // let beforeDate = this.getYearMonth(day?.range?.before)
  65. // let afterDate = this.getYearMonth(day?.range?.after)
  66. // this.beforeYear = beforeDate.year;
  67. // this.beforeMonth = beforeDate.month;
  68. // this.afterYear = afterDate.year;
  69. // this.afterMonth = afterDate.month;
  70. },
  71. getDataThen(list, total, result) {
  72. this.totalMoney = result.totalMoney
  73. this.totalWithdraw = result.totalWithdraw
  74. this.list = result.page.records
  75. this.total = result.page.total
  76. },
  77. openTimePicker() {
  78. this.$refs.datetimePicker.open();
  79. },
  80. onTimeChange(e) {
  81. // todo
  82. console.log('--onTimeChange', e)
  83. },
  84. requestMerchantTransferH5(item, fn) {
  85. // #ifdef H5
  86. // 使用Vue原型上的jWeixin
  87. const jWeixin = this.$jWeixin
  88. if (!jWeixin) {
  89. console.error('jWeixin未初始化')
  90. uni.showToast({
  91. title: '微信环境异常',
  92. icon: 'none'
  93. })
  94. return
  95. }
  96. jWeixin.ready(() => {
  97. jWeixin.checkJsApi({
  98. jsApiList: ['requestMerchantTransfer'],
  99. success: (res) => {
  100. if (res.checkResult['requestMerchantTransfer']) {
  101. // H5环境下使用WeixinJSBridge
  102. if (typeof WeixinJSBridge !== 'undefined') {
  103. WeixinJSBridge.invoke('requestMerchantTransfer', {
  104. appId: this.$config.appId,
  105. mchId: this.$config.mchId,
  106. package: item.packageInfo,
  107. }, (res) => {
  108. if (res.err_msg === 'requestMerchantTransfer:ok') {
  109. // 提现成功后的处理
  110. fn && fn()
  111. } else {
  112. console.log('提现失败:', res)
  113. uni.showToast({
  114. title: '提现失败,请稍后再试',
  115. icon: 'none'
  116. })
  117. }
  118. })
  119. } else {
  120. console.error('WeixinJSBridge未找到')
  121. uni.showToast({
  122. title: '请在微信中打开',
  123. icon: 'none'
  124. })
  125. }
  126. } else {
  127. uni.showToast({
  128. title: '你的微信版本过低,请更新至最新版本',
  129. icon: 'none'
  130. })
  131. }
  132. },
  133. fail: (error) => {
  134. console.error('checkJsApi失败:', error)
  135. uni.showToast({
  136. title: '微信接口检查失败',
  137. icon: 'none'
  138. })
  139. }
  140. })
  141. })
  142. jWeixin.error((res) => {
  143. console.error('微信配置失败:', res)
  144. uni.showToast({
  145. title: '微信配置失败',
  146. icon: 'none'
  147. })
  148. })
  149. // #endif
  150. },
  151. withdraw(item) {
  152. // #ifdef H5
  153. // 检查是否在微信环境
  154. if (!this.isInWechat()) {
  155. uni.showToast({
  156. title: '请在微信中打开',
  157. icon: 'none'
  158. })
  159. return
  160. }
  161. // H5环境下使用专门的H5提现方法
  162. this.requestMerchantTransferH5(item, () => {
  163. this.$store.commit('getUserInfo')
  164. this.$store.commit('getRiceInfo')
  165. this.$api('getMoney', {
  166. id: item.id,
  167. }).then(res => {
  168. this.getData()
  169. })
  170. })
  171. return
  172. // #endif
  173. // #ifdef MP-WEIXIN
  174. // 小程序环境下的处理
  175. // 拉起微信收款确认页面
  176. if (!wx.canIUse('requestMerchantTransfer')) {
  177. wx.showModal({
  178. content: '你的微信版本过低,请更新至最新版本。',
  179. showCancel: false,
  180. });
  181. return
  182. }
  183. // 在真机环境中,调用API
  184. wx.requestMerchantTransfer({
  185. appId: wx.getAccountInfoSync().miniProgram.appId,
  186. mchId: this.$config.mchId,
  187. package: item.packageInfo,
  188. success: (res) => {
  189. this.$store.commit('getUserInfo')
  190. this.$store.commit('getRiceInfo')
  191. this.$api('getMoney', {
  192. id: item.id,
  193. }).then(res => {
  194. this.getData()
  195. })
  196. },
  197. fail: (res) => {
  198. console.log('fail:', res);
  199. uni.showToast({
  200. title: '提现失败,请稍后再试',
  201. icon: 'none'
  202. })
  203. },
  204. complete: (res) => {
  205. console.log('requestMerchantTransfer完成:', res);
  206. }
  207. });
  208. // #endif
  209. },
  210. // #ifdef H5
  211. // 检查是否在微信环境
  212. isInWechat() {
  213. const ua = navigator.userAgent.toLowerCase()
  214. return ua.indexOf('micromessenger') !== -1
  215. },
  216. }
  217. }
  218. </script>
  219. <style lang="scss" scoped>
  220. .page {
  221. background-color: $uni-bg-color;
  222. min-height: 100vh;
  223. /deep/ .nav-bar__view {
  224. background-image: linear-gradient(#84A73F, #D8FF8F);
  225. }
  226. }
  227. .uni-color-btn {
  228. padding: 10rpx 20rpx;
  229. margin: 0;
  230. font-size: 26rpx;
  231. margin-left: 20rpx;
  232. }
  233. .tools {
  234. background-color: $uni-fg-color;
  235. padding: 25rpx 42rpx;
  236. .btn {
  237. display: inline-block;
  238. border: none;
  239. color: #000000;
  240. font-size: 28rpx;
  241. line-height: 40rpx;
  242. &-icon {
  243. width: 28rpx;
  244. height: 28rpx;
  245. margin-left: 12rpx;
  246. }
  247. }
  248. }
  249. .list {
  250. margin: 9rpx 13rpx;
  251. padding: 31rpx 20rpx;
  252. &-item {
  253. padding-bottom: 19rpx;
  254. border-bottom: 1rpx solid #E0E0E0;
  255. margin-bottom: 20rpx;
  256. font-size: 28rpx;
  257. &-icon {
  258. width: 56rpx;
  259. height: auto;
  260. margin-right: 10rpx;
  261. }
  262. &-info {
  263. flex: 1;
  264. color: #949494;
  265. .highlight {
  266. color: #333333;
  267. }
  268. }
  269. &-value {
  270. color: #FF2A2A;
  271. }
  272. }
  273. }
  274. </style>