index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <div class="prepaidRefill">
  3. <div class="input_phone">
  4. <div class="flex_r flex_jb flex_ac">
  5. <textarea v-model="qda.phoneno" placeholder="请输入手机号" @input="inphone" @confirm="inphone" :auto-height="true" class="inp dinB" placeholder-class="inpc" />
  6. <div class="ico iconfont" @click="openContact">&#xe8fb;</div>
  7. </div>
  8. <div class="phonemsg" v-if="gameArea">{{ gameArea }}</div>
  9. </div>
  10. <div class="items">
  11. <div class="tit">充话费</div>
  12. <div class="li flex_r">
  13. <div :class="{ li_it: 1, active: qda.cardnum == i.money }" v-for="(i, s) in CallingList" :key="s" @click="selectMoney(i)" >{{ i.money }}元</div>
  14. </div>
  15. </div>
  16. <div class="money card">
  17. <div class="li flex_r flex_jb">
  18. <span>消费金额</span>
  19. <span>¥{{ selectItem.custom_price == 0 ? selectItem.money : selectItem.custom_price }}</span>
  20. </div>
  21. <div class="li flex_r flex_jb">
  22. <span>消费券抵扣</span>
  23. <span class="corg">-¥{{ selectItem.custom_integral || 0 }}</span>
  24. </div>
  25. <div class="li flex_r flex_jb">
  26. <span>实付金额</span>
  27. <span>¥{{ selectItem.actual_price || 0 }}</span>
  28. </div>
  29. </div>
  30. <div class="money card mar_b60">
  31. <div class="li flex_r flex_jb">
  32. <span>赠送茶宝</span>
  33. <span>{{ selectItem.chabao || 0 }}</span>
  34. </div>
  35. </div>
  36. <div class="msgbar">
  37. <div class="tit">话费充值说明</div>
  38. <div class="msg_con">
  39. <p v-for="(i,s) in Desc" :key="s">{{ i }}</p>
  40. </div>
  41. </div>
  42. <div class="footbtn" @click="onpay">立即支付</div>
  43. </div>
  44. </template>
  45. <script>
  46. import { ToPayOpre } from "@/utils/reqTools.js";
  47. let toPayOpre = new ToPayOpre();
  48. import { post } from "@/request/api.js";
  49. export default {
  50. name: "prepaidRefill",
  51. props: {},
  52. components: {},
  53. data() {
  54. return {
  55. CallingList: [], //可充话费列表
  56. qda: {
  57. phoneno: "",
  58. cardnum: 100,
  59. },
  60. userinfo: uni.getStorageSync("userinfo"),
  61. gameArea: "",
  62. selectItem: {},
  63. Desc: {}, //充值说明
  64. };
  65. },
  66. methods: {
  67. openContact() {
  68. let that = this;
  69. uni.chooseContact({
  70. success: (res) => {
  71. setTimeout(() => {
  72. that.qda.phoneno = res.phoneNumber;
  73. that.inphone();
  74. }, 80);
  75. },
  76. fail: (err) => {
  77. console.log("获取通讯录失败:", err);
  78. },
  79. });
  80. },
  81. selectMoney(va){
  82. this.selectItem = va
  83. this.qda.cardnum = va.money
  84. this.qda.attachment = JSON.stringify(va)
  85. },
  86. getCallingList() {
  87. post("local/ofpay/getMoney").then((res) => {
  88. if (res.code == 0) {
  89. this.CallingList = res.data;
  90. this.selectMoney(res.data[0]);
  91. this.inphone();
  92. }
  93. });
  94. },
  95. inphone() {
  96. if (this.checkPhone(this.qda.phoneno)) {
  97. post("local/ofpay/telCheck", this.qda).then((res) => {
  98. if (res.code == 0) {
  99. post("local/ofpay/telQuery", this.qda).then((res) => {
  100. if (res.code == 0) {
  101. if (res.data.error_code == 0) {
  102. this.gameArea = res.data.result.game_area;
  103. }
  104. }
  105. });
  106. }
  107. });
  108. }
  109. },
  110. checkPhone(phone) {
  111. if (/^1[3456789]\d{9}$/.test(phone)) {
  112. return true;
  113. } else {
  114. return false;
  115. }
  116. },
  117. onpay() {
  118. let that = this
  119. let localInfo = uni.getStorageSync("localInfo");
  120. let um = localInfo.property;
  121. let str = um > this.selectItem.actual_price ? "将优先使用余额支付" : "将使用余额抵扣部分支付"
  122. if(um > 0){
  123. uni.showModal({
  124. title: "温馨提示",
  125. content: `您的数智生活余额 ${um} 元,` + str,
  126. showCancel: true,
  127. confirmText: "确认",
  128. confirmColor: "#f02f2f",
  129. success(res) {
  130. if (res.confirm) {
  131. that.payok();
  132. }
  133. },
  134. });
  135. }else this.payok();
  136. },
  137. payok(){
  138. let type = "";
  139. // #ifdef H5
  140. type = "H5";
  141. // #endif
  142. // #ifdef APP
  143. type = "app";
  144. // #endif
  145. // #ifdef MP-WEIXIN
  146. type = "jsapi";
  147. // #endif
  148. this.qda.trade_type = type
  149. post("local/ofpay/onlineorde", this.qda).then((res) => {
  150. if(res.data && res.data != 200){
  151. let data = JSON.parse(res.data)
  152. data.prepayid = data.package?data.package.split('prepay_id=')[1]:''
  153. if (res.code == 0 && data.prepayid) {
  154. toPayOpre.toPay(data, (rea) => {
  155. if (!rea) {
  156. // 支付成功
  157. this.goto("/pagesB/orderingfood/orderlist");
  158. } else {
  159. // 支付失败
  160. }
  161. });
  162. }
  163. }else if (res.code == 0 && res.data == 200) this.goto("/pagesB/orderingfood/orderlist")
  164. });
  165. },
  166. getdesc() {
  167. post("local/ofpay/desc").then((res) => {
  168. if (res.code == 0) {
  169. this.Desc = res.data[0];
  170. }
  171. });
  172. },
  173. },
  174. onLoad(da) {
  175. this.qda.phoneno = this.userinfo.mobile;
  176. this.getCallingList();
  177. this.getdesc();
  178. },
  179. watch: {},
  180. onShow() {},
  181. mounted() {},
  182. };
  183. </script>
  184. <style scoped lang='scss'>
  185. .prepaidRefill {
  186. min-height: 100vh;
  187. background-color: #fff;
  188. padding: 28rpx 32rpx;
  189. }
  190. .input_phone {
  191. border-bottom: 1rpx solid rgba($color: #000, $alpha: 0.15);
  192. padding: 12rpx 16rpx;
  193. margin-bottom: 60rpx;
  194. .inp {
  195. font-size: 40rpx;
  196. }
  197. .ico{
  198. font-size: 50rpx;
  199. font-weight: bold;
  200. }
  201. .phonemsg {
  202. width: 100%;
  203. font-size: 24rpx;
  204. margin-top: 12rpx;
  205. color: #666;
  206. }
  207. }
  208. .items {
  209. margin-bottom: 60rpx;
  210. .tit {
  211. font-size: 26rpx;
  212. color: #666;
  213. margin-bottom: 20rpx;
  214. }
  215. .li {
  216. display: grid;
  217. justify-content: space-between;
  218. grid-template-columns: repeat(auto-fill, 210rpx);
  219. }
  220. .li_it {
  221. font-size: 38rpx;
  222. font-weight: 600;
  223. width: 210rpx;
  224. text-align: center;
  225. height: 120rpx;
  226. line-height: 120rpx;
  227. border-radius: 12rpx;
  228. border: 1rpx solid rgba($color: #000, $alpha: 0.15);
  229. margin-bottom: 16rpx;
  230. color: #555;
  231. &.active {
  232. color: #18bb88;
  233. border-color: #18bb88;
  234. box-shadow: 4rpx 4rpx 16rpx 10rpx rgba($color: #18bb88, $alpha: 0.1);
  235. }
  236. }
  237. }
  238. .money {
  239. .li {
  240. margin-bottom: 16rpx;
  241. &:last-child {
  242. margin-bottom: 0;
  243. }
  244. span {
  245. font-size: 30rpx;
  246. }
  247. }
  248. .corg {
  249. color: #18bb88;
  250. margin-left: 12rpx;
  251. }
  252. }
  253. .msgbar{
  254. padding-bottom: 160rpx;
  255. .tit{
  256. font-size: 32rpx;
  257. font-weight: bold;
  258. margin: 80rpx 0 20rpx;
  259. }
  260. .msg_con{
  261. font-size: 26rpx;
  262. p{
  263. margin-bottom: 10rpx;
  264. }
  265. }
  266. }
  267. .card {
  268. background-color: #fff;
  269. border-radius: 16rpx;
  270. margin-bottom: 30rpx;
  271. padding: 28rpx 30rpx;
  272. font-size: 32rpx;
  273. box-shadow: 4rpx 4rpx 8rpx 4rpx rgba(0, 0, 0, 0.12);
  274. &:last-child {
  275. margin-bottom: 0;
  276. }
  277. }
  278. .footbtn {
  279. width: calc(100% - 60rpx);
  280. height: 80rpx;
  281. background: #17bb87;
  282. border-radius: 45rpx;
  283. position: fixed;
  284. bottom: 50rpx;
  285. left: 30rpx;
  286. color: #fff;
  287. font-size: 36rpx;
  288. text-align: center;
  289. line-height: 80rpx;
  290. }
  291. </style>
  292. <style lang='scss'>
  293. .prepaidRefill {
  294. .inpc {
  295. font-size: 34rpx;
  296. }
  297. }
  298. </style>