shop-recharge.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. <template>
  2. <view class="shop-recharge-container">
  3. <view class="total-pane">
  4. <view class="itemHeader">
  5. <image :src="common.seamingImgUrl(shopInfo.shopLogo)" mode="" class="avatar"></image>
  6. <text class="topTitle">{{ shopInfo.shopName }}</text>
  7. <!-- <view class="openMerchanDetail" @click="gotoMerchan">
  8. <text class="gotoUse">立即使用</text><image class="useMoney" src="@/static/images/entryOfMerchants/youjiantou.png"></image>
  9. </view> -->
  10. </view>
  11. <view class="pane-1">
  12. <!-- <view>当前余额</view> -->
  13. <view class="account"> {{ shopInfo.balance }} <image class="eye-icon"
  14. src="../../../static/images/new-user/shop-serve/eye-close.png"></image>
  15. </view>
  16. <!-- <view class="total-account">当前赠送余额: {{ shopInfo.giveBalance }}元</view> -->
  17. </view>
  18. <view class="pane-2">
  19. <view class="item">
  20. <view class="item-title">剩余代金卷</view>
  21. <view class="item-value">
  22. {{shopInfo.giveBalance}}
  23. </view>
  24. </view>
  25. <view class="item" @click="go('/another-tf/another-user/shop-recharge/historyRecord')">
  26. <view class="item-title">充值记录(元)</view>
  27. <view class="item-value">
  28. {{ shopInfo.balance }}
  29. </view>
  30. </view>
  31. <view class="item">
  32. <view class="item-title">支出记录(元)</view>
  33. <view class="item-value">
  34. 0.00
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="tab-wrapper">
  40. <!-- <tui-tabs backgroundColor="#fff" sliderBgColor="#EF530E" sliderRadius="0" unlined color="#222229"
  41. selectedColor="#222229" :tabs="tabs" itemWidth="50%" :currentTab="currentTab" @change="handleChnage"></tui-tabs> -->
  42. </view>
  43. <view class="recharge-pane">
  44. <!-- <view class="title-wrapper">
  45. <view class="sub-title">请选择充值商家</view>
  46. </view> -->
  47. <view class="search-shop" v-if="!shopId">
  48. <input type="text" class="input" placeholder="请选择充值商家">
  49. <button class="uni-btn search-shop-btn" @click="handleSearchSop">查找</button>
  50. </view>
  51. <view class="title-wrapper">
  52. <view class="sub-title">余额充值</view>
  53. <view class="tip">充值送代金券</view>
  54. </view>
  55. <view class="price-list" v-if="rechargePriceList && rechargePriceList.length > 0">
  56. <view @click="handleChangePrice(item.rechargeAmount, index)" class="item" :class="{ active: currentRechargeType === index }"
  57. v-for="(item, index) in rechargePriceList" :key="item.updateTime">
  58. <view class="price-text">{{ item.rechargeAmount }}</view>
  59. <view class="voucher">{{ '代金卷' + item.bonusAmount + '元' || '自定义金额' }}</view>
  60. </view>
  61. </view>
  62. <view class="price-list" v-else>
  63. <view class="tipsTitle">
  64. 商户暂未开通充值
  65. </view>
  66. </view>
  67. <button v-if="rechargePriceList && rechargePriceList.length > 0" class="recharge-button uni-btn" :style="{ opacity: currentRechargeCount ? 1 : 0.6 }"
  68. @click="showPayTypePopup = true"> {{ currentRechargeCount ? `${currentRechargeCount} 立即充值` : '请输入充值金额' }} </button>
  69. </view>
  70. <tui-bottom-popup :show="showPayTypePopup" @close="showPayTypePopup = false">
  71. <view v-if="showPayTypePopup" style="padding: 60upx 0 128upx;">
  72. <CashierList :price-pay="currentRechargeCount" show show-platform-pay @change="(e) => payInfo = e" />
  73. <tui-button
  74. type="warning" width="168upx" height="64upx" margin="30upx auto 0"
  75. shape="circle"
  76. @click="handleRecharge"
  77. >
  78. 确认支付
  79. </tui-button>
  80. </view>
  81. </tui-bottom-popup>
  82. <tui-toast ref="toast"></tui-toast>
  83. </view>
  84. </template>
  85. <script>
  86. import { getRechargeSubmitApi, addRechargeSubmitApi, getRechargeTotalCustomersApi, getByShopAllApi, getByRechargeApi, getIndexShopDetailApi } from '@/api/anotherTFInterface'
  87. import { handleDoPay } from '@/utils/payUtil'
  88. export default {
  89. data() {
  90. return {
  91. shopId: '',
  92. currentTab: 0,
  93. shopInfo: {},
  94. // tabs: [{
  95. // name: "平台充值"
  96. // }, {
  97. // name: "商家充值"
  98. // }],
  99. rechargePriceList: [],
  100. currentRechargeType: 0,
  101. currentRechargeCount: 50,
  102. searchShopValue: "",
  103. showPayTypePopup: false,
  104. payInfo: {},
  105. }
  106. },
  107. onLoad(options) {
  108. this.shopInfo = JSON.parse(options.shopInfo)
  109. this.shopId = this.shopInfo.shopId
  110. // getByShopAllApi().then(res => {
  111. // this.historyMerchantNumber = res.data.records.length
  112. // })
  113. // getIndexShopDetailApi({
  114. // shopId: this.shopId
  115. // }).then(res => {
  116. // this.shopInfo = res.data
  117. // })
  118. // getByRechargeApi({
  119. // "page":"1",
  120. // "pageSize":"10"
  121. // }).then(res => {
  122. // console.log(res);
  123. // })
  124. getRechargeSubmitApi({
  125. shopId: this.shopId
  126. }).then(res => {
  127. this.rechargePriceList = Object.freeze(res.data)
  128. this.currentRechargeCount = this.rechargePriceList[0].rechargeAmount
  129. // console.log(res);
  130. })
  131. getRechargeTotalCustomersApi({ // 空数据,先不作处理
  132. shopId: this.shopId
  133. }).then(res => {
  134. console.log(res);
  135. })
  136. },
  137. methods: {
  138. handleChnage({ index }) {
  139. this.currentTab = index
  140. },
  141. handleChangePrice(price, index) {
  142. this.currentRechargeType = index
  143. this.currentRechargeCount = price
  144. console.log(this.currentRechargeType,this.currentRechargeCount);
  145. },
  146. handleRecharge() {
  147. if (!this.currentRechargeCount) {
  148. this.ttoast({
  149. type: "fail",
  150. title: '请选择要充值的金额'
  151. })
  152. return
  153. }
  154. addRechargeSubmitApi({
  155. shopId: this.shopId,
  156. amountId: this.rechargePriceList[this.currentRechargeType].amountId,
  157. rechargeBalance: this.currentRechargeCount,
  158. remark: 'normal'
  159. }).then(res => {
  160. handleDoPay({ ...res.data, ...this.payInfo }, 7)
  161. console.log(res);
  162. }).catch(err => {
  163. console.log(err);
  164. })
  165. console.log("八嘎雅鹿,你滴良心,大大滴坏。");
  166. },
  167. handleSearchSop() {
  168. if (!this.searchShopValue) {
  169. this.ttoast({
  170. type: 'info',
  171. title: '请输入商家名称'
  172. })
  173. return
  174. }
  175. }
  176. },
  177. }
  178. </script>
  179. <style lang="less" scoped>
  180. .itemHeader {
  181. box-sizing: border-box;
  182. padding: 32rpx;
  183. padding-bottom: 0rpx;
  184. position: relative;
  185. width: 100%;
  186. display: flex;
  187. align-items: center;
  188. // margin-bottom: 20rpx;
  189. /* justify-content: space-between; */
  190. .avatar {
  191. width: 80rpx;
  192. height: 80rpx;
  193. border-radius: 50%;
  194. }
  195. .topTitle {
  196. margin-left: 20rpx;
  197. justify-self: flex-start;
  198. width: 353rpx;
  199. overflow: hidden;
  200. white-space: nowrap;
  201. text-overflow: ellipsis;
  202. font-size: 42rpx;
  203. font-weight: 600;
  204. line-height: 40rpx;
  205. color: #f5f5f5;
  206. }
  207. .openMerchanDetail {
  208. position: absolute;
  209. right: 0;
  210. .gotoUse {
  211. font-size: 38rpx;
  212. font-weight: normal;
  213. line-height: 32rpx;
  214. color: #ffffff;
  215. margin-right: 10rpx;
  216. }
  217. .useMoney {
  218. width: 18rpx;
  219. height: 24rpx;
  220. }
  221. }
  222. }
  223. .shop-recharge-container {
  224. .total-pane {
  225. z-index: 1;
  226. position: relative;
  227. width: 100%;
  228. // height: 413upx;
  229. background: linear-gradient(90deg, #EF530E 0%, #EF530E 100%);
  230. display: flex;
  231. align-items: center;
  232. flex-direction: column;
  233. position: relative;
  234. &::after {
  235. content: '';
  236. width: 624upx;
  237. height: 675upx;
  238. display: block;
  239. position: absolute;
  240. left: -344upx;
  241. top: -100upx;
  242. background: url('../../../static/images/new-user/shop-serve/accoount-bg.png') no-repeat;
  243. background-size: contain;
  244. }
  245. .pane-1 {
  246. flex: 1;
  247. display: flex;
  248. align-items: center;
  249. justify-content: center;
  250. font-size: 28upx;
  251. color: #fff;
  252. flex-direction: column;
  253. .eye-icon {
  254. width: 40upx;
  255. height: 40upx;
  256. flex-shrink: 0;
  257. margin-left: 65upx;
  258. }
  259. .account {
  260. display: flex;
  261. align-items: center;
  262. font-size: 64upx;
  263. font-weight: 500;
  264. margin-bottom: 10rpx;
  265. // margin: 20upx 0;
  266. }
  267. .total-account {
  268. font-size: 28upx;
  269. color: #f6a07a;
  270. // margin-top: 10rpx;
  271. margin-bottom: 26rpx;
  272. }
  273. }
  274. .pane-2 {
  275. display: flex;
  276. align-items: center;
  277. width: 100%;
  278. height: 112upx;
  279. .item {
  280. position: relative;
  281. flex: 1;
  282. height: 100%;
  283. display: flex;
  284. align-items: center;
  285. justify-content: center;
  286. flex-direction: column;
  287. background: linear-gradient(to bottom, #f16426, #ef540f);
  288. padding: 18upx 56upx 18upx 56upx;
  289. box-sizing: border-box;
  290. color: #fff;
  291. &::after {
  292. display: block;
  293. position: absolute;
  294. right: 0;
  295. top: 50%;
  296. transform: translateY(-50%);
  297. content: '';
  298. width: 1upx;
  299. height: 48upx;
  300. background-color: #f6a07a;
  301. z-index: 10;
  302. }
  303. &:nth-child(3) {
  304. &::after {
  305. display: none;
  306. }
  307. }
  308. &-title {
  309. font-size: 24upx;
  310. color: #f8b598;
  311. }
  312. &-value {
  313. font-size: 28upx;
  314. margin-top: 4upx;
  315. line-height: 1.5;
  316. }
  317. }
  318. }
  319. }
  320. .tab-wrapper {
  321. background-color: #fff;
  322. display: flex;
  323. align-items: center;
  324. justify-content: center;
  325. margin-top: 20upx;
  326. }
  327. .recharge-pane {
  328. position: relative;
  329. z-index: 2;
  330. padding: 30upx 50upx 84upx;
  331. box-sizing: border-box;
  332. .search-shop {
  333. display: flex;
  334. align-items: center;
  335. padding: 26upx 0;
  336. border-bottom: 2upx solid #F3F3F3;
  337. margin-bottom: 68upx;
  338. .input {
  339. flex: 1;
  340. font-size: 32upx;
  341. }
  342. .search-shop-btn {
  343. position: relative;
  344. padding-left: 16upx;
  345. font-size: 28upx;
  346. color: #EF520E;
  347. &::after {
  348. content: '';
  349. width: 1upx;
  350. height: 220upx;
  351. display: block;
  352. left: 0;
  353. top: 50%;
  354. background-color: #F3F3F3;
  355. transform: translateY(-50%);
  356. }
  357. }
  358. }
  359. .title-wrapper {
  360. display: flex;
  361. align-items: center;
  362. justify-content: space-between;
  363. font-size: 32upx;
  364. color: #222229;
  365. margin-bottom: 38upx;
  366. .tip {
  367. color: #888889;
  368. font-size: 26upx;
  369. }
  370. }
  371. .price-list {
  372. display: flex;
  373. align-items: center;
  374. gap: 24rpx;
  375. // justify-content: space-between;
  376. flex-wrap: wrap;
  377. .tipsTitle {
  378. margin-top: 40rpx;
  379. width: 100%;
  380. text-align: center;
  381. font-size: 40rpx;
  382. color: #888889;
  383. }
  384. .item {
  385. width: 200upx;
  386. height: 200upx;
  387. display: flex;
  388. align-items: center;
  389. justify-content: center;
  390. background-color: #f4f4f4;
  391. flex-direction: column;
  392. margin-bottom: 24upx;
  393. border-radius: 10upx;
  394. font-size: 52upx;
  395. color: #222229;
  396. font-size: 500;
  397. box-sizing: border-box;
  398. .voucher {
  399. color: #888889;
  400. font-size: 28upx;
  401. margin-top: 18upx;
  402. }
  403. &.active {
  404. border: 2upx solid #EF520E;
  405. color: #EF520E;
  406. background: #FFF5F3;
  407. }
  408. }
  409. }
  410. .recharge-button {
  411. display: flex;
  412. align-items: center;
  413. justify-content: center;
  414. margin-top: 120upx;
  415. height: 88upx;
  416. border-radius: 16upx;
  417. font-size: 32upx;
  418. color: #fff;
  419. background: linear-gradient(287deg, #EF530E 31%, #F77A42 104%);
  420. box-shadow: 0px 2px 2px 0px #FA6842, 0px 5px 20px 0px rgba(250, 104, 66, 0.8);
  421. transition: all 350ms;
  422. &:active {
  423. opacity: 0.7;
  424. }
  425. }
  426. }
  427. }
  428. </style>