recharge.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <template>
  2. <app-layout>
  3. <view class="dir-top-nowrap recharge" v-if="pageShow">
  4. <view class="account">我的账户</view>
  5. <view :style="{'background-image': `url(${appImg.mall.balance_recharge})`}"
  6. class="dir-left-nowrap bg cross-center">
  7. <image class="image box-grow-0" src="./image/icon-balance.png"></image>
  8. <view class="balance-text box-grow-1">{{customPage.balance_title}}</view>
  9. <view class="balance-price box-grow-0">{{balance}}</view>
  10. </view>
  11. <view class="amount-text">{{customPage.recharge_amount_title}}</view>
  12. <view class="dir-left-wrap select">
  13. <view v-for="(item,index) in list" :key="index" @click="setPrice(index)"
  14. class="dir-top-nowrap cross-center main-center box" :class="index === selected? 'active':''">
  15. <view class="price">充{{ item.pay_price }}元</view>
  16. <view class="send" v-if="item.send_price > 0">送{{ item.send_price }}元</view>
  17. <view class="send" v-if="item.send_integral > 0">送{{ item.send_integral }}积分</view>
  18. <view class="send dir-left-nowrap cross-center" v-if="item.member">
  19. <view class="t-omit">送{{ item.member.name }}</view>
  20. <view class="box-grow-0 member-info main-center cross-center"
  21. @click.stop="navMember(item.member)">详情
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="input" :class="selected === -1 && getFocus ? `red`: `grey`" v-if="setting.type === `1`">
  27. <input @focus="bindFocus" placeholder-style="color:#bbbbbb" v-model="pay_price" type="digit"
  28. :focus="getFocus"
  29. @blur="bludBlur"
  30. @input="changeInput"
  31. :placeholder="`手动输入` + customPage.recharge_amount_title"/>
  32. </view>
  33. <view class="btn">
  34. <app-button @click="submit"
  35. :round-size="customPage.recharge_btn_radius+ `rpx`"
  36. :color="customPage.recharge_btn_color"
  37. height="88"
  38. :border-color="customPage.recharge_btn_background"
  39. :background="customPage.recharge_btn_background">{{customPage.recharge_btn_title}}
  40. </app-button>
  41. </view>
  42. <view class="account">{{customPage.recharge_explanation_title}}</view>
  43. <app-text class="text" :content="setting.explain"></app-text>
  44. </view>
  45. </app-layout>
  46. </template>
  47. <script>
  48. import {mapState} from 'vuex';
  49. import appText from '../../components/basic-component/app-rich/parse.vue';
  50. export default {
  51. name: "recharge",
  52. computed: {
  53. ...mapState({
  54. customPage: state => state.mallConfig.recharge_page_custom,
  55. appImg: state => state.mallConfig.__wxapp_img,
  56. }),
  57. },
  58. data() {
  59. return {
  60. setting: null,
  61. list: null,
  62. pay_price: '',
  63. balance: '¥',
  64. selected: -1,
  65. getFocus: false,
  66. pageShow: false,
  67. }
  68. },
  69. onShow: function () {
  70. this.loadData();
  71. },
  72. components: {
  73. appText
  74. },
  75. watch: {
  76. pay_price: {
  77. handler: function (newData, oldData) {
  78. if (newData) {
  79. this.selected = -1;
  80. }
  81. }
  82. }
  83. },
  84. methods: {
  85. navMember: function (member) {
  86. uni.navigateTo({
  87. url: `/pages/member/upgrade/upgrade?level=${member.level}`
  88. });
  89. },
  90. getSetting: function () {
  91. const self = this;
  92. self.$request({
  93. url: self.$api.balance.index,
  94. }).then(info => {
  95. if (info.code === 0) {
  96. self.pageShow = true;
  97. if (info.data.setting.status === `1`) {
  98. self.setting = info.data.setting;
  99. self.balance = '¥' + info.data.balance;
  100. } else {
  101. uni.showModal({
  102. title: '提示',
  103. content: '尚未开启余额功能',
  104. showCancel: false,
  105. confirmText: '确定',
  106. success(e) {
  107. if (e.confirm) {
  108. uni.navigateBack({delta: 1})
  109. }
  110. }
  111. });
  112. }
  113. }
  114. })
  115. },
  116. loadData: function () {
  117. const self = this;
  118. self.getSetting();
  119. self.$showLoading({title: `加载中`});
  120. self.$request({
  121. url: self.$api.recharge.index,
  122. }).then(info => {
  123. self.$hideLoading();
  124. if (info.code === 0) {
  125. self.list = info.data.list;
  126. }
  127. }).catch(info => {
  128. self.$hideLoading();
  129. })
  130. },
  131. bindFocus: function () {
  132. this.selected = -1;
  133. this.getFocus = true;
  134. },
  135. bludBlur: function () {
  136. this.getFocus = false;
  137. },
  138. changeInput(e) {
  139. },
  140. setPrice: function (index) {
  141. this.pay_price = '';
  142. this.selected = index;
  143. },
  144. submit: function () {
  145. const self = this;
  146. let para;
  147. if (self.selected === -1) {
  148. if (self.pay_price > 0) {
  149. para = {
  150. id: 0,
  151. pay_price: self.pay_price,
  152. send_price: 0
  153. };
  154. } else {
  155. uni.showToast({
  156. title: '金额不能为空',
  157. icon: 'none',
  158. });
  159. return;
  160. }
  161. } else {
  162. para = {
  163. id: self.list[self.selected].id,
  164. pay_price: self.list[self.selected].pay_price,
  165. send_price: self.list[self.selected].send_price,
  166. }
  167. }
  168. self.$showLoading({title: `加载中`});
  169. self.$request({
  170. url: self.$api.recharge.balance_recharge,
  171. data: para,
  172. method: 'POST',
  173. }).then(info => {
  174. self.$hideLoading();
  175. if (info.code === 0) {
  176. self.$payment.pay(info.data.pay_id).then(e => {
  177. uni.showModal({
  178. title: '提示',
  179. content: '充值成功!',
  180. showCancel: false,
  181. confirmText: '确定',
  182. success(e) {
  183. if (e.confirm) {
  184. uni.navigateBack({delta: 1})
  185. }
  186. }
  187. });
  188. }).catch(e => {
  189. //uni.showToast({'title': e, icon: 'none'});
  190. });
  191. } else {
  192. uni.showToast({'title': info.msg, icon: 'none'});
  193. }
  194. }).catch(info => {
  195. self.$hideLoading();
  196. })
  197. }
  198. }
  199. }
  200. </script>
  201. <style lang="scss">
  202. page {
  203. background: #FFFFFF;
  204. }
  205. </style>
  206. <style scoped lang="scss">
  207. .recharge {
  208. background: #FFFFFF;
  209. padding: #{40rpx} #{24rpx} 0;
  210. .btn .app-view .app-secondary {
  211. border-width: 0px !important;
  212. }
  213. .account {
  214. font-size: #{24rpx};
  215. border-left: #{6rpx} solid #ff4544;
  216. padding-left: #{24rpx};
  217. color: #666666;
  218. margin-bottom: #{32}rpx;
  219. }
  220. .bg {
  221. background-repeat: no-repeat;
  222. background-size: #{702rpx} #{160rpx};
  223. height: #{160rpx};
  224. width: #{702rpx};
  225. color: #666666;
  226. .image {
  227. width: #{72rpx};
  228. height: #{72rpx};
  229. margin-left: #{40rpx};
  230. }
  231. .balance-text {
  232. font-size: #{42rpx};
  233. margin-left: #{20rpx}
  234. }
  235. .balance-price {
  236. font-size: #{46rpx};
  237. margin-right: #{56rpx};
  238. }
  239. }
  240. .amount-text {
  241. font-size: #{24rpx};
  242. color: #999999;
  243. margin-top: #{56rpx};
  244. }
  245. .select {
  246. margin: 0 #{-12rpx};
  247. .box {
  248. height: #{183rpx};
  249. width: #{339rpx};
  250. margin: #{24rpx} #{12rpx} 0 #{12rpx};
  251. padding: 0 24#{rpx};
  252. border: #{1px} solid #cccccc;
  253. border-radius: #{16rpx};
  254. .price {
  255. font-size: #{32rpx};
  256. font-weight: bold;
  257. color: #666666;
  258. }
  259. .send {
  260. font-size: #{24rpx};
  261. color: #999999;
  262. }
  263. .member-info {
  264. border: 1#{rpx} solid #999999;
  265. border-radius: 24#{rpx};
  266. height: 30#{rpx};
  267. width: 60#{rpx};
  268. font-size: 18#{rpx};
  269. margin-left: 10#{rpx};
  270. }
  271. }
  272. .active {
  273. border: #{1px} solid #ff4544;
  274. .price {
  275. color: #ff4544
  276. }
  277. .send {
  278. color: #ff4544;
  279. }
  280. .member-info {
  281. border-color: #ff4544;
  282. }
  283. }
  284. }
  285. .input {
  286. margin-top: #{40rpx};
  287. border-radius: #{14rpx};
  288. input {
  289. color: #666666;
  290. height: #{88rpx};
  291. padding: 0 #{12rpx};
  292. }
  293. }
  294. .input.red {
  295. border: #{1px} solid #ff4544;
  296. }
  297. .input.grey {
  298. border: #{1px} solid #cccccc;
  299. }
  300. .btn {
  301. margin-top: #{56rpx};
  302. margin-bottom: #{72rpx};
  303. }
  304. .text {
  305. margin-top: -8rpx;
  306. }
  307. }
  308. </style>