recharge.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. <template>
  2. <view class="pos-r padding-lr-sm" v-if="fetch && fetch.info" @click="Dever.close()">
  3. <use-tabbar :tabbar="false" />
  4. <view class="border-radius bg-main padding margin-top-sm">
  5. <u-popover position="right" width="200px">
  6. <view class="fwbd fs">{{fetch.info.name}}充值
  7. <view style="margin-left:5px;display: inline-block;">
  8. <u-icon name="question-circle"></u-icon>
  9. </view>
  10. </view>
  11. <template v-slot:content>
  12. <view style="color: white;">
  13. <u-parse :content="fetch.info.exp_tip"></u-parse>
  14. </view>
  15. </template>
  16. </u-popover>
  17. <!-- 金额选项 -->
  18. <view class="dflex money-area flex-wrap">
  19. <view class="item dflex-c dflex-flow-c" :class="{ active: config === index }"
  20. v-for="(item, index) in fetch.config" :key="index" @click="setConfig(index)">
  21. <view class="price">{{ item.price }}</view>
  22. <text class="fs-xs">到账{{ item.value_text }}</text>
  23. </view>
  24. </view>
  25. <!-- 输入其他金额 -->
  26. <input class="w-full padding border-radius-sm bg-drak" type="number" placeholder="请输入其他数值" v-model="number"
  27. maxlength="140" @input="setConfig(-1)"/>
  28. <!-- 马上充值按钮 -->
  29. <view class="dflex-c w-full margin-tb" @click="act">
  30. <view class="dflex-c dflex-flow-c border-radius-lg padding-tb-sm fwb line-height-1 cur_bgcolor"
  31. style="width: 70vw;">
  32. <text>马上充值</text>
  33. <text class="fs-xxs margin-top-xs ft-dark-4">并同意积分服务协议</text>
  34. </view>
  35. </view>
  36. <!-- 协议提示 -->
  37. <view class="margin-top dflex-c" @click="Dever.location('tool/page?title=积分服务协议')">
  38. <text class="cur_color margin-left-xs fs-xs padding-tb">积分服务协议</text>
  39. </view>
  40. </view>
  41. <!-- 记录列表 -->
  42. <view class="record-list margin-top-sm" v-if="fetch">
  43. <view class="record-title fs fwbd ft-black margin-bottom-sm">充值记录</view>
  44. <view v-if="fetch['list_' + current] && fetch['list_' + current].length > 0">
  45. <view class="record-item" v-for="(item, index) in fetch['list_' + current]" :key="index">
  46. <view class="record-left">
  47. <view class="record-name">{{ item.action_name }}</view>
  48. <view class="record-desc" v-if="item.desc">{{ item.desc }}</view>
  49. <view class="record-time">{{ item.cdate }}</view>
  50. </view>
  51. <view class="record-amount" :class="{ income: item.amount > 0, expense: item.amount < 0 }">
  52. {{ item.amount > 0 ? '+' : '' }}{{ item.amount }}
  53. </view>
  54. </view>
  55. </view>
  56. <view v-else class="empty-record">
  57. <u-empty mode="data"></u-empty>
  58. </view>
  59. </view>
  60. <view class="safe-area-inset-bottom"></view>
  61. </view>
  62. </template>
  63. <script>
  64. import Pay from '@/lib/dever/pay.js'
  65. export default {
  66. data() {
  67. return {
  68. config: 0, // 默认选中第一个
  69. fetch: {},
  70. id: 0,
  71. current: 0,
  72. number: '',
  73. };
  74. },
  75. onLoad(options) {
  76. if (options && options.id) {
  77. this.id = options.id;
  78. } else {
  79. this.Dever.location('source/home');
  80. return;
  81. }
  82. },
  83. onShow() {
  84. this.loadData();
  85. this.loadList(1);
  86. },
  87. //下拉刷新
  88. onPullDownRefresh() {
  89. this.loadList(1);
  90. },
  91. //加载更多
  92. onReachBottom() {
  93. this.loadList(2);
  94. },
  95. methods: {
  96. setConfig(index) {
  97. if (this.config == index) {
  98. this.config = -1;
  99. } else {
  100. this.config = index;
  101. }
  102. },
  103. loadData() {
  104. this.DeverApi.get(this, 'score.recharge', {
  105. id: this.id
  106. });
  107. },
  108. loadList(page) {
  109. this.DeverApi.page([page, 'list_' + this.current], this, 'score.rechargeLog', {
  110. id: this.id
  111. });
  112. },
  113. act() {
  114. var number = this.number;
  115. if (number) {
  116. number = parseFloat(number);
  117. } else {
  118. number = 0;
  119. }
  120. if (this.config < 0 && number <= 0) {
  121. return this.Dever.alert('您没有要充值的金额?');
  122. }
  123. var recharge_id = 0;
  124. if (this.config >= 0) {
  125. recharge_id = this.fetch.config[this.config].id
  126. }
  127. this.DeverApi.post('score.rechargeAct', {id:this.id,recharge_id:recharge_id,number:number}, r => {
  128. if (typeof r.pay == 'boolean') {
  129. if (r.pay) {
  130. this.yes(r)
  131. } else {
  132. this.Dever.alert('充值失败');
  133. }
  134. } else {
  135. Pay.payment(r.order_num, r.pay, res => {
  136. this.Dever.success('充值成功', () => {
  137. this.yes(r)
  138. })
  139. }, err => {
  140. this.Dever.alert('充值失败', () => {
  141. this.yes(r)
  142. })
  143. })
  144. }
  145. });
  146. },
  147. yes(r) {
  148. console.info(r)
  149. this.Dever.location('score/info?id=' + this.id, 'go')
  150. },
  151. },
  152. };
  153. </script>
  154. <style lang="scss">
  155. .money-area {
  156. margin-top: 28rpx;
  157. margin-bottom: 18rpx;
  158. display: flex;
  159. flex-wrap: wrap;
  160. gap: 18rpx;
  161. /* 加这个 */
  162. .item {
  163. width: calc((100% - 2 * 18rpx) / 3);
  164. /* 3个元素,间隔2个gap */
  165. height: 152rpx;
  166. background: #f5f5f5;
  167. border-radius: 12rpx;
  168. box-sizing: border-box;
  169. padding: 20rpx;
  170. text-align: center;
  171. .price {
  172. color: #333;
  173. margin-bottom: 8rpx;
  174. }
  175. text {
  176. color: #9a9a9a;
  177. }
  178. }
  179. .active {
  180. background: #ff696b;
  181. color: #fff;
  182. .price,
  183. text {
  184. color: #fff !important;
  185. }
  186. }
  187. }
  188. .record-list {
  189. background: #ffffff;
  190. border-radius: 20rpx;
  191. padding: 30rpx;
  192. .record-title {
  193. font-size: 30rpx;
  194. font-weight: bold;
  195. color: #333;
  196. }
  197. .record-item {
  198. display: flex;
  199. justify-content: space-between;
  200. align-items: center;
  201. padding: 20rpx 0;
  202. border-bottom: 1px solid #f0f0f0;
  203. &:last-child {
  204. border-bottom: none;
  205. }
  206. .record-left {
  207. display: flex;
  208. flex-direction: column;
  209. .record-name {
  210. font-size: 28rpx;
  211. color: #333;
  212. }
  213. .record-desc {
  214. font-size: 28rpx;
  215. color: #999;
  216. }
  217. .record-time {
  218. font-size: 24rpx;
  219. color: #999;
  220. margin-top: 6rpx;
  221. }
  222. }
  223. .record-amount {
  224. font-size: 28rpx;
  225. font-weight: bold;
  226. &.income {
  227. color: #4caf50;
  228. }
  229. &.expense {
  230. color: #f44336;
  231. }
  232. }
  233. }
  234. }
  235. .empty-record {
  236. text-align: center;
  237. padding: 60rpx 0;
  238. .empty-icon {
  239. width: 160rpx;
  240. height: 160rpx;
  241. margin-bottom: 20rpx;
  242. opacity: 0.6;
  243. }
  244. .empty-text {
  245. font-size: 28rpx;
  246. color: #999;
  247. }
  248. }
  249. .cur_bgcolor {
  250. background: #ff696b;
  251. color: #fff;
  252. }
  253. .cur_color {
  254. color: #ff696b;
  255. }
  256. .u-popover {
  257. width: 180rpx !important;
  258. }
  259. </style>