index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <template>
  2. <view class="container">
  3. <!-- <view class="list flex_r flex_ac flex_jb mar_t16">
  4. <view class="list_name">充值类型:</view>
  5. <view class="title_select">
  6. <picker @change="bindPickerChange" :value="index" :range="array">
  7. <view class="flex_r flex_ac flex_je" style="width: 300rpx">
  8. <view class="select_name">{{ array[index] }}</view>
  9. <image
  10. style="width: 25rpx; height: 25rpx; margin-left: 15rpx"
  11. src="/static/down.png"
  12. mode=""
  13. >
  14. </image>
  15. </view>
  16. </picker>
  17. </view>
  18. </view> -->
  19. <view class="con">
  20. <view class="list flex_r flex_ac">
  21. <view class="list_name">当前余额:</view>
  22. <input
  23. class="list_input flex_grow"
  24. type="text"
  25. v-model="userinfo.user_money"
  26. readonly
  27. placeholder="当前余额"
  28. />
  29. </view>
  30. <view class="list flex_r flex_ac">
  31. <view class="list_name">充值金额:</view>
  32. <input
  33. class="list_input flex_grow"
  34. type="text"
  35. v-model="price"
  36. placeholder="请输入充值金额"
  37. />
  38. </view>
  39. <view class="list flex_r flex_ac">
  40. <view class="list_name">支付方式:</view>
  41. <view class="flex_r flex_ac">
  42. <!-- <view class="way_radio select_way"></view> -->
  43. <view class="way_con flex_r flex_ac">
  44. <image
  45. class="way_img"
  46. src="/static/weixin_icon.png"
  47. mode=""
  48. ></image>
  49. <view class="way_text">微信支付</view>
  50. </view>
  51. </view>
  52. <!-- <input
  53. class="list_input flex_grow"
  54. type="text"
  55. v-model="price"
  56. placeholder="请输入充值金额"
  57. /> -->
  58. </view>
  59. <div class="checkbox-box flex_r flex_ac">
  60. <checkbox-group @change="checkboxChange" class="flex_r flex_ac">
  61. <label class="checkbox flex_r flex_ac">
  62. <checkbox class="checkboxCom" value="agree" />
  63. <view>我同意</view>
  64. </label>
  65. <navigator url="/pages/agreement/privacy" hover-class="li_hover"
  66. ><text>《充值协议》</text></navigator
  67. >
  68. </checkbox-group>
  69. </div>
  70. <!-- <view class="privacy">
  71. <navigator url="/pages/agreement/privacy" hover-class="li_hover"><text>查看《隐私协议》</text></navigator>
  72. </view> -->
  73. <view class="btn flex_r flex_ac flex_jc" @tap="confimTopUp"
  74. >立即充值</view
  75. >
  76. <view>
  77. <image class="adv_img" :src="advertisingImg" ></image>
  78. </view>
  79. </view>
  80. <!-- <view class="list flex_r flex_ac flex_jb mar_t16" v-if="index == 0">
  81. <view class="list_name">当前余额:</view>
  82. <view class="list_text flex_r flex_ac flex_je"
  83. ><text>¥</text>{{ userinfo.user_money }}</view
  84. >
  85. </view>
  86. <view class="list flex_r flex_ac flex_jb mar_t16">
  87. <view class="list_name">充值金额:</view>
  88. <view class="list_text flex_r flex_ac">
  89. <input
  90. type="text"
  91. v-model="price"
  92. placeholder="自定义金额"
  93. placeholder-style="color:#ddd;"
  94. />
  95. </view>
  96. </view>
  97. <view class="option flex_c mar_t16">
  98. <view class="list_name">充值方式</view>
  99. <view class="option_con flex_r flex_ac flex_jb mar_t16">
  100. <view class="way_con flex_r flex_ac">
  101. <image class="way_img" src="/static/weixin_icon.png" mode=""></image>
  102. <view class="way_text">微信支付</view>
  103. </view>
  104. <view
  105. class="way_radio"
  106. :class="isSelect == 1 ? 'select_way' : ''"
  107. ></view>
  108. </view>
  109. </view>
  110. <view class="btn flex_r flex_ac flex_jc" @tap="confimTopUp">立即充值</view> -->
  111. </view>
  112. </template>
  113. <script>
  114. let app = getApp();
  115. var appEv = app.$vm.$options;
  116. import { ToPayOpre } from "@/utils/reqTools.js";
  117. var toPayOpre = new ToPayOpre();
  118. import { post } from "@/request/api.js";
  119. export default {
  120. data() {
  121. return {
  122. price: "",
  123. isSelect: 1,
  124. detail: {},
  125. array: ["余额充值"],
  126. index: 0,
  127. userinfo: undefined, // 获取用户信息
  128. isDisabled: false, //是否选中协议
  129. advertisingImg: "", //广告图片
  130. };
  131. },
  132. onLoad: function () {
  133. this.userinfo = uni.getStorageSync("userinfo");
  134. this.getAdvImg();
  135. },
  136. methods: {
  137. confimTopUp() {
  138. console.log(this.isDisabled,"qqqq")
  139. if (this.price == 0 || this.prioce == "") {
  140. appEv.errTips("充值不能为0");
  141. return;
  142. } else if (!this.isDisabled) {
  143. appEv.errTips("请阅读并同意相关协议");
  144. return;
  145. } else {
  146. // #ifdef H5
  147. let type = "H5";
  148. // #endif
  149. // #ifdef APP
  150. let type = "app";
  151. // #endif
  152. // #ifdef MP-WEIXIN
  153. let type = "jsapi";
  154. // #endif
  155. let data = {
  156. trade_type: type,
  157. amount: this.price,
  158. };
  159. post("/user/recharge", data).then((res) => {
  160. toPayOpre.toPay(res.data.data, (rea) => {
  161. if (!rea) {
  162. // 支付成功
  163. appEv.errTips("支付成功");
  164. this.price = 0;
  165. this.getuserInfo();
  166. } else {
  167. // 支付失败
  168. appEv.errTips("支付已取消");
  169. }
  170. });
  171. });
  172. }
  173. },
  174. getAdvImg() {
  175. post("/adImgages").then((res) => {
  176. if (res.code === 0) {
  177. console.log(res.data.data);
  178. this.advertisingImg = res.data.data;
  179. }
  180. });
  181. },
  182. getuserInfo() {
  183. post("/user/userinfo").then((res) => {
  184. if (res.code === 0) {
  185. uni.setStorageSync("userinfo", res.data.data);
  186. this.userinfo = res.data.data;
  187. }
  188. });
  189. },
  190. checkboxChange(e) {
  191. var value = e.detail.value;
  192. if(value.length == 0){
  193. this.isDisabled = false
  194. }else{
  195. this.isDisabled = true
  196. }
  197. },
  198. },
  199. };
  200. </script>
  201. <style lang="scss" scoped>
  202. // 页面配置
  203. page {
  204. background: #f4f4f4;
  205. }
  206. // 页面配置-end
  207. // 页面内容
  208. .con {
  209. width: 1005;
  210. overflow: hidden;
  211. padding: 30rpx;
  212. box-sizing: border-box;
  213. }
  214. .adv_img {
  215. margin-top: 20px;
  216. width: 690rpx;
  217. // height: 100%;
  218. height: 345rpx;
  219. }
  220. .list {
  221. width: 100%;
  222. height: 100rpx;
  223. border-bottom: 3rpx solid rgba(0, 0, 0, 0.12);
  224. }
  225. .list_name {
  226. font-size: 28rpx;
  227. color: #333333;
  228. font-weight: "SourceHanSansCN-Medium";
  229. width: 130rpx;
  230. }
  231. .list_input {
  232. width: calc(100% - 140rpx);
  233. margin-left: 10rpx;
  234. height: 100%;
  235. font-size: 28rpx;
  236. color: #333;
  237. }
  238. .btn {
  239. width: 395rpx;
  240. height: 95rpx;
  241. border-radius: 10rpx;
  242. background: #17bb87;
  243. color: #fff;
  244. font-size: 34rpx;
  245. font-family: "SourceHanSansCN-Medium";
  246. margin: 100rpx auto 0;
  247. }
  248. // 提交内容-end
  249. .checkbox-box {
  250. margin-top: 60rpx;
  251. margin-bottom: -20px;
  252. font-size: 28rpx;
  253. }
  254. .checkbox-box text {
  255. /* color: #07d; */
  256. /* color: #44A92F; */
  257. color: #44a92f;
  258. }
  259. .checkbox-box .checkbox .checkboxCom {
  260. transform: scale(0.84);
  261. -webkit-transform: scale(0.84);
  262. }
  263. .way_radio {
  264. width: 39rpx;
  265. height: 35rpx;
  266. background: url("~@/static/sgin/weixuanzhong_icon.png");
  267. background-repeat: no-repeat;
  268. background-size: 35rpx 35rpx;
  269. background-position: center center;
  270. }
  271. .select_way {
  272. background: url("~@/static/sgin/xuanzhong_icon.png");
  273. background-repeat: no-repeat;
  274. background-size: 39rpx 35rpx;
  275. background-position: center center;
  276. }
  277. .way_img {
  278. width: 52rpx;
  279. height: 52rpx;
  280. margin-right: 8rpx;
  281. }
  282. .way_text {
  283. font-size: 22rpx;
  284. color: #333333;
  285. font-family: "SourceHanSansCN-Medium";
  286. }
  287. // 页面内容-end
  288. </style>