pay-zfb.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. <template>
  2. <view class="login-main">
  3. <view style="width: 100%">
  4. <view style="width: 100%;height: 270rpx;">
  5. <image class="img" src="../../static/images/payBack.png" style="width: 100%;height: 100%;"></image>
  6. </view>
  7. </view>
  8. <view class="main">
  9. <view class="login-main-content">
  10. <image class="img" :src="shopInfo.store_logo_url
  11. ? shopInfo.store_logo_url
  12. : '/static/images/error.jpeg'
  13. " mode=""></image>
  14. <h4 class="shopName">
  15. 陕西天枢云 {{ shopInfo ? shopInfo.store_name : "" }}
  16. </h4>
  17. </view>
  18. <view class="login-contont">
  19. <view class="uInput">
  20. <u-input placeholder="请输入金额" border="bottom" :fontSize="40" type="digit" v-model="price"
  21. :customStyle="inpustyle">
  22. <span slot="prefix" style="font-size: 30px">¥</span>
  23. </u-input>
  24. </view>
  25. <view class="login-contont-button">
  26. <button class="btn" @click="Pay">立即支付</button>
  27. <view style="padding: 0px 30rpx;">
  28. <view style="margin-top: 66rpx;background: #FFF7F6;">
  29. <u-cell-group :border="false">
  30. <u-cell title="代金券折扣" value="可使用4个" :border="false"></u-cell>
  31. </u-cell-group>
  32. </view>
  33. <view style="margin-top: 20rpx; font-size: 26rpx">
  34. 支付成功后,次日将有随机奖励红包以及店铺代金券,可抵现金花,AI天枢云小程序领取
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. <u-popup :zIndex="200" :overlayStyle="{ zIndex: 200 }" :show="showPhone" @close="close" @open="open"
  41. :safeAreaInsetTop="true" round="20">
  42. <view class="popup">
  43. <view class="header">
  44. <h4>绑定手机号</h4>
  45. <p class="tip">注意:首次登录,需绑定手机号才可成功领取农商网红包</p>
  46. </view>
  47. <view class="main">
  48. <view style="height: 70rpx">
  49. <u--input placeholder="请输入手机号" type="number" border="surround" v-model="phone"
  50. style="background: #f4f4f4; height: 100%" />
  51. </view>
  52. <view style="margin-top: 20px; height: 70rpx">
  53. <u--input placeholder="验证码" border="surround" v-model="yzm"
  54. style="background: #f4f4f4; height: 100%">
  55. <template slot="suffix">
  56. <u-code ref="uCode" @change="codeChange" seconds="60" changeText="X秒重新获取"></u-code>
  57. <!-- <u-button @tap="getCode" :text="tips" type="success" size="mini"></u-button> -->
  58. <text class="yzm" @tap="getCode">{{
  59. tips ? tips : "发送验证码"
  60. }}</text>
  61. </template>
  62. </u--input>
  63. </view>
  64. </view>
  65. <view class="footer">
  66. <u-button type="primary" class="btn" text="确定" @click="submitOk"></u-button>
  67. </view>
  68. </view>
  69. </u-popup>
  70. </view>
  71. </template>
  72. <script>
  73. import api from "@/api/index.js";
  74. import ap from "../../static/zfb.js"
  75. import {
  76. requestConfig
  77. } from "@/app.config.js";
  78. export default {
  79. data() {
  80. return {
  81. ap: ap,
  82. showPhone: false,
  83. requestConfig: requestConfig,
  84. code: "",
  85. appid: "",
  86. value: "",
  87. userInfo: {},
  88. inpustyle: {
  89. fontWeight: "bold",
  90. fontSize: "40px",
  91. },
  92. phone: "",
  93. yzm: "",
  94. tips: null,
  95. price: null,
  96. shopId: "",
  97. shopInfo: {},
  98. zfbInfo: {},
  99. shopId: "",
  100. localUserInfo: {},
  101. uid: ""
  102. };
  103. },
  104. onLoad(options) {
  105. console.log('options', options);
  106. this.zfbInfo = options
  107. this.uid = options.uid || ""
  108. this.shopId = options.shopId
  109. let info = localStorage.getItem('aliPayUserInfo');
  110. this.localUserInfo = JSON.parse(info)
  111. if (this.localUserInfo) {
  112. this.getShopInfo();
  113. } else {
  114. this.getInfo();
  115. }
  116. },
  117. methods: {
  118. async getInfo() {
  119. api.alipayLogin({
  120. code: this.zfbInfo.auth_code
  121. }).then(res => {
  122. if (res.code == 200) {
  123. this.userInfo = res.data;
  124. localStorage.setItem('aliPayUserInfo', JSON.stringify(this.userInfo))
  125. if (this.userInfo.bindPhoneStatus == 0) {
  126. this.showPhone = true
  127. } else {
  128. this.showPhone = false
  129. this.getShopInfo()
  130. }
  131. } else {
  132. uni.$u.toast('获取登录信息失败!');
  133. }
  134. })
  135. },
  136. async Pay() {
  137. uni.showLoading({
  138. title: '支付中'
  139. });
  140. if (!this.price) {
  141. uni.$u.toast('请输入支付金额!');
  142. }
  143. api.payOrder({
  144. shopType: this.shopInfo.shopType,
  145. shopUserId: this.shopInfo.shopUserId,
  146. shopId: this.shopInfo.shopId,
  147. payAmount: Number(this.price),
  148. payWay: 7,
  149. userId: this.localUserInfo.userId
  150. }).then(res => {
  151. if (res.code == 200) {
  152. uni.hideLoading();
  153. window.location.href =
  154. `alipays://platformapi/startapp?appId=20000067&url=${encodeURIComponent(pay.data.data.result)}`
  155. } else {
  156. uni.hideLoading();
  157. uni.$u.toast(pay.data.msg);
  158. }
  159. })
  160. }
  161. },
  162. async getShopInfo() {
  163. api.getStoreInfoByScan({
  164. shopId: this.zfbInfo.shopId,
  165. uid: this.uid
  166. }).then(res => {
  167. if (res.code == 200) {
  168. this.shopInfo = res.data
  169. } else {
  170. uni.$u.toast(res.msg);
  171. }
  172. });
  173. },
  174. async submitOk() {
  175. if (this.phone == "") {
  176. uni.$u.toast('请输入手机号');
  177. } else if (this.yzm == "") {
  178. uni.$u.toast('请输入验证码');
  179. }
  180. api.bindH5Phone({
  181. phone: this.phone,
  182. code: this.yzm,
  183. password: 123456,
  184. confirmPassword: 123456,
  185. type: 0
  186. }).then(res => {
  187. if (res.code == 200) {
  188. uni.$u.toast('绑定手机号成功');
  189. this.userInfo = res.data
  190. this.showPhone = false
  191. this.getShopInfo()
  192. } else {
  193. uni.$u.toast(res.msg);
  194. }
  195. })
  196. },
  197. async getCode() {
  198. if (this.$refs.uCode.canGetCode) {
  199. uni.showLoading({
  200. title: '正在获取验证码'
  201. })
  202. api.sendSms({
  203. phone: this.phone,
  204. type: 0
  205. }).then(res => {
  206. if (res.code == 200) {
  207. uni.hideLoading();
  208. uni.$u.toast('验证码已发送');
  209. this.$refs.uCode.start();
  210. } else {
  211. uni.$u.toast('倒计时结束后再发送');
  212. }
  213. })
  214. }
  215. },
  216. };
  217. </script>
  218. <style lang="scss" scoped>
  219. ::v-deep .u-cell__title {
  220. flex: none !important;
  221. }
  222. .main {
  223. width: 100%;
  224. background: white;
  225. height: calc(100% - 280rpx);
  226. border-radius: 40rpx;
  227. }
  228. .shopName {
  229. font-weight: bold;
  230. font-size: 36rpx;
  231. color: #333333;
  232. }
  233. /* 修改加载提示框的遮罩层 z-index */
  234. .uni-loading__mask {
  235. z-index: 10076;
  236. }
  237. /* 修改加载提示框本身的 z-index */
  238. .uni-loading {
  239. z-index: 10076;
  240. }
  241. .yzm {
  242. font-weight: 500;
  243. font-size: 28rpx;
  244. color: #00d36d;
  245. }
  246. .popup {
  247. height: 300px;
  248. padding: 20px;
  249. .footer {
  250. margin-top: 150rpx;
  251. .btn {
  252. width: 100%;
  253. background: linear-gradient(152deg, #6F9DFD 0%, #1B71F2 100%);
  254. border-radius: 46rpx;
  255. border: none;
  256. }
  257. }
  258. .main {
  259. margin-top: 20rpx;
  260. }
  261. .header {
  262. margin-bottom: 20rpx;
  263. text-align: center;
  264. .tip {
  265. margin-top: 20rpx;
  266. font-weight: 500;
  267. font-size: 26rpx;
  268. color: #ff8b2f;
  269. }
  270. }
  271. }
  272. .u-radio-group--row {
  273. justify-content: center;
  274. }
  275. .radioText {
  276. font-weight: 500;
  277. font-size: 24rpx;
  278. color: #999999;
  279. line-height: 34rpx;
  280. text-align: left;
  281. font-style: normal;
  282. }
  283. .login-main {
  284. background: url("../../static/images/payBack.png");
  285. background-size: 100% 100%;
  286. width: 100%;
  287. display: flex;
  288. flex-direction: column;
  289. /* justify-content: space-between; */
  290. align-items: center;
  291. height: 100vh;
  292. }
  293. .login-contont-button {
  294. text-align: center;
  295. .btn {
  296. margin-top: 20px;
  297. width: 95%;
  298. height: 90rpx;
  299. background: linear-gradient(152deg, #6F9DFD 0%, #1B71F2 100%);
  300. border-radius: 44rpx;
  301. color: #fff;
  302. }
  303. }
  304. .login-contont {
  305. width: 100%;
  306. height: 600rpx;
  307. margin-top: 100rpx;
  308. .uInput {
  309. padding: 10px 0px;
  310. border-bottom: 0.5px solid #97979740;
  311. }
  312. .login-contont-info {
  313. text-align: center;
  314. .text {
  315. margin-top: 10px;
  316. font-weight: 500;
  317. font-size: 28rpx;
  318. color: #999999;
  319. line-height: 40rpx;
  320. font-style: normal;
  321. }
  322. }
  323. }
  324. .radio {
  325. text-align: center;
  326. margin-top: 10px;
  327. }
  328. .login-main-content {
  329. display: flex;
  330. flex-direction: row;
  331. align-items: center;
  332. padding: 9px 26px;
  333. .img {
  334. // margin-top: 70px;
  335. margin-right: 20rpx;
  336. width: 44rpx;
  337. height: 44rpx;
  338. border-radius: 50%;
  339. }
  340. }
  341. </style>