topUp.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. <template>
  2. <view class="topUpContainer">
  3. <VoucherBalance :user-acount="userAcount"></VoucherBalance>
  4. <view v-show="isGift" class="selectAcount">
  5. <tui-form ref="giftForm">
  6. <tui-input v-model="findUserId" :border-bottom="false" label="转增账号" placeholder="请输入用户ID / 手机号">
  7. <button slot="right" class="selectBtn" @click="getUserInfo">查询</button>
  8. </tui-input>
  9. <view v-if="findUserInfo" class="selectUserInfo">
  10. <image v-if="findUserInfo.oldTF.avatarUrl" class="userAvatar" :src="findUserInfo.oldTF.avatarUrl"></image>
  11. <image v-else class="userAvatar" src="../../../../static/images/new-user/default-user-avatar.png"></image>
  12. <text class="userName">{{ findUserInfo.oldTF.nickName }}</text>
  13. </view>
  14. <!-- <tui-input @input="getCustomValue(amountData.length-1)" @focus="customNumber" type="number" :borderBottom="false" label="转增金额" min="0" max="20000" placeholder="请输入金额" v-model="amountData[amountData.length-1].value">
  15. <button class="selectBtn" slot="right">充值</button>
  16. </tui-input> -->
  17. </tui-form>
  18. <!-- <view class="moneys">
  19. 可用金额:{{ userAcount.number || '0.00' }} 元
  20. </view> -->
  21. </view>
  22. <AmountSelection ref="AmountSelection" v-bind="$props" :amount-data="amountData" @getCustomValue="getCustomValue">
  23. </AmountSelection>
  24. <view class="VoucherService" style="display: none;">
  25. <p class="title">代金卷服务</p>
  26. <view class="VoucherServiceBox">
  27. <view class="VoucherServiceItem">
  28. <image class="icons" src="../../../../static/images/user/qianbao.png"></image>
  29. <text class="texts">充值记录</text>
  30. </view>
  31. <view class="VoucherServiceItem">
  32. <image class="icons" src="../../../../static/images/user/zhuanzheng.png"></image>
  33. <text class="texts">支出记录</text>
  34. </view>
  35. <view class="VoucherServiceItem">
  36. <image class="icons" src="../../../../static/images/user/shouyi.png"></image>
  37. <text class="texts">收益记录</text>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="footer">
  42. <view class="titles">
  43. <text>使用规则</text>|<text>常见问题</text>|<text>联系客服</text>
  44. </view>
  45. <view class="titles2">
  46. 本服务由广东团蜂生活服务有限公司提供
  47. </view>
  48. </view>
  49. <view class="footerButton">
  50. <button v-if="!isGift" class="fuckBtn" @click="amount && (isShowModalRecharge = true)">
  51. ¥{{ amount
  52. }}&nbsp;立即充值
  53. </button>
  54. <button
  55. v-else class="fuckBtn" :loading="isLoding" :disabled="isLoding"
  56. @click="giveAmount && (isShowModalRecharge = true)"
  57. >
  58. &nbsp;立即转赠
  59. </button>
  60. </view>
  61. <tui-modal
  62. :show="isShowModalRecharge" custom fadein :button="[]"
  63. :z-index="995" :mask-z-index="994"
  64. @cancel="isShowModalRecharge = false"
  65. >
  66. <view style="padding: 28upx 0;text-align: center;">
  67. <view>
  68. <image style="width: 435upx;height: 337upx;" src="../../../../static/images/common/modal-show.png"></image>
  69. </view>
  70. <view style="margin-top: 24upx;font-size: 40upx;color: #333333;">
  71. <text v-if="isGift">确定要转赠 {{ giveAmount }} 代金券吗?</text>
  72. <text v-else>确定要充值 {{ amount * 2 }} 代金券吗?</text>
  73. </view>
  74. <view style="margin-top: 22upx;font-size: 36upx;color: #687383;">
  75. <text v-if="isGift">价值 {{ amount }} 元</text>
  76. <text v-else>共需支付 {{ amount }} 元</text>
  77. </view>
  78. <view>
  79. <tui-button
  80. v-if="isGift" type="warning" width="238rpx" height="108rpx"
  81. margin="32upx 0 0" :size="40"
  82. shape="circle"
  83. style="display: inline-block;background: #ef530e!important;box-shadow: 0px 12px 20px 0px #f1ac8e;"
  84. @click="giftVouchers"
  85. >
  86. 确定
  87. </tui-button>
  88. <tui-button
  89. v-else type="warning" width="238rpx" height="108rpx"
  90. margin="32upx 0 0" :size="40" shape="circle"
  91. style="display: inline-block;background: #ef530e!important;box-shadow: 0px 12px 20px 0px #f1ac8e;"
  92. @click="showPayTypePopup = true"
  93. >
  94. 确定
  95. </tui-button>
  96. </view>
  97. </view>
  98. </tui-modal>
  99. <tui-bottom-popup :show="showPayTypePopup" @close="showPayTypePopup = false">
  100. <view v-if="showPayTypePopup" style="padding: 60upx 0 128upx;">
  101. <CashierList :price-pay="amount" show show-platform-pay @change="(e) => payInfo = e" />
  102. <tui-button
  103. type="warning" width="168upx" height="64upx" margin="30upx auto 0"
  104. shape="circle"
  105. @click="submitVouchers"
  106. >
  107. 确认支付
  108. </tui-button>
  109. </view>
  110. </tui-bottom-popup>
  111. </view>
  112. </template>
  113. <script>
  114. import { submitVoucherOrderApi, updateTransferVoucherShopHoldApi, getBandUserInfoApi } from '../../../../api/anotherTFInterface'
  115. import VoucherBalance from '../cpns/VoucherBalance.vue'
  116. import AmountSelection from '../cpns/AmountSelection.vue'
  117. import { handleDoPay } from '../../../../utils/payUtil'
  118. export default {
  119. components: {
  120. VoucherBalance,
  121. AmountSelection
  122. },
  123. props: {
  124. userAcount: {
  125. type: Object,
  126. default: {}
  127. },
  128. userInfo: {
  129. type: Object,
  130. default: {}
  131. },
  132. isGift: {
  133. type: Boolean,
  134. default: false
  135. }
  136. },
  137. data() {
  138. return {
  139. amountData: [{ value: 50, price: 25 },
  140. { value: 100, price: 50 },
  141. { value: 200, price: 100 },
  142. { value: 2000, price: 1000 },
  143. { value: 4000, price: 2000 },
  144. { value: 0, price: 0 }],
  145. amount: 25,
  146. giveAmount: 50,
  147. findUserId: '',
  148. findUserInfo: null,
  149. isShowKeyboard: false,
  150. isLoding: false,
  151. isShowModalRecharge: false,
  152. showPayTypePopup: false,
  153. payInfo: {}
  154. }
  155. },
  156. methods: {
  157. getCustomValue(index, valueNum) {
  158. console.log(index, valueNum)
  159. if (valueNum) this.amountData[index].value = valueNum
  160. this.amountData[index].price = this.amountData[index].value / 2
  161. this.amount = this.amountData[index].price
  162. this.giveAmount = this.amountData[index].value
  163. },
  164. submitVouchers() {
  165. submitVoucherOrderApi({
  166. voucherId: '1',
  167. number: this.amount * 2,
  168. payGrade: this.amount
  169. }).then((res) => {
  170. handleDoPay({ ...res.data, ...this.payInfo }, 4)
  171. })
  172. .catch((err) => {
  173. console.log(err)
  174. })
  175. },
  176. getUserInfo() {
  177. const regExp = /^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[1589]))\d{8}$/
  178. if (regExp.exec(this.findUserId)) { // 手机号
  179. getBandUserInfoApi({
  180. type: 2,
  181. value: this.findUserId
  182. }).then((res) => {
  183. this.findUserInfo = {
  184. oldTF: {
  185. avatarUrl: res.data.headImage,
  186. nickName: res.data.phone
  187. },
  188. newTF: res.data
  189. }
  190. })
  191. .catch((err) => {
  192. this.findUserInfo = null
  193. })
  194. } else {
  195. getBandUserInfoApi({
  196. type: 1,
  197. value: this.findUserId
  198. }).then((res) => {
  199. this.findUserInfo = {
  200. oldTF: {
  201. avatarUrl: res.data.headImage,
  202. nickName: res.data.phone
  203. },
  204. newTF: res.data
  205. }
  206. })
  207. .catch((err) => {
  208. this.findUserInfo = null
  209. })
  210. }
  211. },
  212. customNumber() {
  213. this.$refs.AmountSelection.active = this.amountData.length - 1
  214. },
  215. giftVouchers() {
  216. if (!this.findUserInfo) return this.$showToast('请选择赠送对象')
  217. if (!this.amount || this.amount <= 0) return this.$showToast('赠送金额大于需大于0')
  218. this.isLoding = true
  219. updateTransferVoucherShopHoldApi({
  220. 'buyerUserId': this.findUserInfo.newTF.buyerUserId,
  221. 'voucherNum': this.giveAmount
  222. }).then((res) => {
  223. this.isLoding = false
  224. uni.showToast({
  225. title: '转增成功',
  226. icon: 'none'
  227. })
  228. this.$emit('getVouvher')
  229. uni.navigateTo({
  230. url: `/another-tf/another-user/voucher/orderStatus?istopUp=${0}&orderStatus=${1}&count=${0 - this.giveAmount}`
  231. })
  232. console.log(res)
  233. })
  234. .catch((err) => {
  235. console.log(err)
  236. })
  237. }
  238. }
  239. }
  240. </script>
  241. <style lang="scss" scoped>
  242. .selectUserInfo {
  243. display: flex;
  244. align-items: center;
  245. width: 100%;
  246. box-sizing: border-box;
  247. padding: 20rpx;
  248. .userAvatar {
  249. width: 80rpx;
  250. height: 80rpx;
  251. border-radius: 50%;
  252. }
  253. .userName {
  254. margin-left: 36rpx;
  255. font-size: 42rpx;
  256. }
  257. }
  258. .selectBtn {
  259. width: 92rpx;
  260. height: 47rpx;
  261. border-radius: 50rpx;
  262. background: rgba(255, 56, 12, 0.8784);
  263. display: flex;
  264. justify-content: center;
  265. font-size: 28rpx;
  266. line-height: 47rpx;
  267. white-space: nowrap;
  268. color: #FFFFFF;
  269. }
  270. .topUpContainer {
  271. box-sizing: border-box;
  272. display: flex;
  273. flex-direction: column;
  274. align-items: center;
  275. width: 100vw;
  276. .VoucherService {
  277. margin-top: 24rpx;
  278. box-sizing: border-box;
  279. padding: 21rpx 30rpx 32rpx 30rpx;
  280. width: 690rpx;
  281. height: 238rpx;
  282. border-radius: 20rpx;
  283. background: #FFFFFF;
  284. .title {
  285. font-size: 32rpx;
  286. font-weight: 600;
  287. font-feature-settings: "kern" on;
  288. color: #222229;
  289. }
  290. .VoucherServiceBox {
  291. margin-top: 40rpx;
  292. display: flex;
  293. justify-content: space-around;
  294. .VoucherServiceItem {
  295. display: flex;
  296. flex-direction: column;
  297. align-items: center;
  298. justify-content: space-between;
  299. .icons {
  300. width: 48rpx;
  301. height: 48rpx;
  302. }
  303. .texts {
  304. margin-top: 10rpx;
  305. font-size: 28rpx;
  306. color: #222229;
  307. }
  308. }
  309. }
  310. }
  311. .selectAcount {
  312. box-sizing: border-box;
  313. padding-top: 6rpx;
  314. padding-bottom: 30rpx;
  315. margin-top: 24rpx;
  316. width: 690rpx;
  317. /* height: 322rpx; */
  318. border-radius: 20rpx;
  319. background-color: #fff;
  320. overflow: hidden;
  321. .moneys {
  322. margin-top: 56rpx;
  323. float: right;
  324. margin-right: 30rpx;
  325. font-size: 32rpx;
  326. line-height: 32rpx;
  327. color: #222229;
  328. }
  329. }
  330. .footer {
  331. width: 690rpx;
  332. height: 196rpx;
  333. display: flex;
  334. flex-direction: column;
  335. align-items: center;
  336. .titles {
  337. margin-top: 54rpx;
  338. width: 432rpx;
  339. height: 32rpx;
  340. display: flex;
  341. align-items: center;
  342. justify-content: space-between;
  343. color: #D8D8D8;
  344. >text {
  345. /* margin-top: 4rpx; */
  346. font-size: 24rpx;
  347. font-weight: 350;
  348. line-height: 30rpx;
  349. color: #222229;
  350. }
  351. }
  352. .titles2 {
  353. margin-top: 24rpx;
  354. position: relative;
  355. font-size: 24rpx;
  356. font-weight: 350;
  357. line-height: 32rpx;
  358. color: #888889;
  359. &::before {
  360. content: '';
  361. width: 93rpx;
  362. height: 2rpx;
  363. position: absolute;
  364. background-color: #888889;
  365. left: -110rpx;
  366. top: 50%;
  367. }
  368. &::after {
  369. content: '';
  370. width: 93rpx;
  371. height: 2rpx;
  372. position: absolute;
  373. background-color: #888889;
  374. right: -110rpx;
  375. top: 50%;
  376. }
  377. }
  378. }
  379. .footerButton {
  380. /* position: fixed;
  381. bottom: 0;
  382. left: 0; */
  383. width: 100%;
  384. height: 120rpx;
  385. display: flex;
  386. align-items: center;
  387. background-color: #fff;
  388. padding-bottom: 40rpx;
  389. .fuckBtn {
  390. width: 690rpx;
  391. height: 88rpx;
  392. border-radius: 16rpx;
  393. padding: 20rpx 48rpx;
  394. gap: 19.999998092651367rpx;
  395. background: #FF380C;
  396. font-family: 思源黑体;
  397. font-size: 32rpx;
  398. line-height: 48rpx;
  399. color: #FFFFFF;
  400. }
  401. }
  402. }
  403. </style>