index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. <template>
  2. <div class="app-content" :class="[contentClass]">
  3. <div class="callback-wrap">
  4. <div class="callback-blo">
  5. <block v-if="pageStatus == 1 || pageStatus == 2">
  6. <div class="icon">
  7. <i class="iconfont icondaizhifu"></i>
  8. </div>
  9. </block>
  10. <block v-else>
  11. <div class="status-img">
  12. <img :src="`${constant.imgUrl}/retail/callback/success.png`" alt mode="widthFix" />
  13. </div>
  14. </block>
  15. <div class="status-text app-size-36 app-bold">{{ pageTit }}</div>
  16. <block v-if="pageStatus == 1 || pageStatus == 2">
  17. <div class="price">
  18. <span>¥</span>
  19. <span class="app-size-36 app-bold">{{ totalPrice }}</span>
  20. </div>
  21. <div class="order-num app-color-3">订单号: {{ orderSn }}</div>
  22. </block>
  23. <block v-else-if="pageStatus == 3 && payDiscountPrice >0">
  24. <div>
  25. <span v-if="payDiscountType == 0" class="app-color-2">使用优惠券为您省</span>
  26. <span v-else-if="payDiscountType == 1" class="app-color-2">会员身份为您省</span>
  27. <span v-else-if="payDiscountType == 2" class="app-color-2">随机优惠为您省</span>
  28. <span v-else class="app-color-2">随机优惠为您省</span>
  29. <span class="app-price">{{ payDiscountPrice }}元</span>
  30. </div>
  31. </block>
  32. <block v-if="pageStatus == 1 || pageStatus == 2">
  33. <div class="call-one-btn">
  34. <button v-if="isYeBtnShow" class="button-com red pay-ye" @click="balancePayFn">余额支付</button>
  35. <button class="button-com green pay-wx" @click="wxPayFn">微信支付</button>
  36. </div>
  37. </block>
  38. <block v-else-if="pageStatus == 3 || pageStatus == 4 || pageStatus == 5">
  39. <div class="call-btn-com call-two-btn" v-if="$util.isEmpty(loginInfo)"> <button class="button-com" @click="register()" >注册会员</button> </div>
  40. <div class="call-btn-com call-two-btn"> <button class="button-com default" @click="goBackHome()" >返回首页</button></div>
  41. </block>
  42. </div>
  43. <div class="coupon-wrap" v-if="option.pageStatus == 5">
  44. <div class="coupon-img">
  45. <img :src="`${constant.imgUrl}/retail/callback/coupon.png`" alt mode="widthFix" />
  46. </div>
  47. <div class="qrcode-img">
  48. <img :src="`${constant.imgUrl}/retail/images/extension.png`" alt mode="widthFix" />
  49. </div>
  50. </div>
  51. </div>
  52. <modal-module :show="passwordModal" @cancel="modalCancel" @click="passwordModalClick" :maskClosable="false" title="支付密码" padding="30upx 30upx" >
  53. <template v-slot:content>
  54. <div class="app-modal-input-wrap">
  55. <div class="inp-list-line">
  56. <div class="line-input">
  57. <input type="password" v-model="form.payPassword" :adjust-position="false" class="inp-input" />
  58. </div>
  59. </div>
  60. </div>
  61. </template>
  62. </modal-module>
  63. <alert-module :show="setPassModal" btnText="去设置" btnColor="#FF2842" padding="66upx 24upx 66upx 24upx" @click="hideAlert" >
  64. <div class="go-login-module">
  65. <div>请先设置密码</div>
  66. </div>
  67. </alert-module>
  68. </div>
  69. </template>
  70. <script>
  71. import { mapGetters } from "vuex";
  72. import ModalModule from "@/components/plugin/modal";
  73. import AlertModule from "@/components/plugin/alert";
  74. import wexinPay from "@/utils/pay/wxPay";
  75. import { getShopUser } from "@/utils/auth";
  76. import { balancePay, wxPay } from "@/api/order";
  77. export default {
  78. name: "index",
  79. components: {
  80. ModalModule,
  81. AlertModule
  82. },
  83. data() {
  84. return {
  85. constant: this.$constant,
  86. pageTit: "",
  87. pageStatus: 1,
  88. contentClass: "",
  89. payDiscountPrice: null,
  90. payDiscountType: 0,
  91. passwordModal: false,
  92. form: {
  93. payPassword: ""
  94. },
  95. payCallData: {},
  96. setPassModal: false,
  97. totalPrice:0,
  98. orderSn:''
  99. };
  100. },
  101. computed: {
  102. ...mapGetters({ shopUser: "getShopUser",loginInfo:"getLoginInfo" })
  103. },
  104. methods: {
  105. register(){
  106. let account = uni.getStorageSync('account')
  107. this.$util.pageTo({url: "/pages/login/index?account="+account,type:2})
  108. },
  109. goBackHome(){
  110. this.$util.pageTo({url: "/pages/home/recent",type:3})
  111. },
  112. init() {
  113. this.orderSn = this.option.orderSn ? this.option.orderSn : ''
  114. if(this.option.totalPrice){
  115. this.totalPrice = parseFloat(Number(this.option.totalPrice))
  116. }
  117. this.pageStatus = this.option.pageStatus;
  118. this.payDiscountPrice = this.option.payDiscountPrice;
  119. this.payDiscountType = this.option.payDiscountType;
  120. this.initClass(this.pageStatus);
  121. getShopUser(true);
  122. },
  123. _balancePay() {
  124. if (!this.form.payPassword) {
  125. this.$msg("请先输入支付密码!");
  126. return false;
  127. }
  128. balancePay({
  129. payPassword: this.form.payPassword,
  130. orderSn: this.orderSn,
  131. couponId: this.option.couponId
  132. }).then(res => {
  133. this.modalCancel();
  134. this.$msg("支付成功!");
  135. this.payCallData = res.data;
  136. this.paySuccess();
  137. })
  138. },
  139. // 微信支付
  140. wxPayFn() {
  141. let miniOpenId = uni.getStorageSync('miniOpenId')
  142. wxPay({ orderSn: this.orderSn, couponId: this.option.couponId,miniOpenId:miniOpenId }).then(res => {
  143. this.payCallData = res.data
  144. wexinPay(res.data, this.paySuccess, this.payFail)
  145. this.orderSn = res.data.orderSn ? res.data.orderSn : ''
  146. })
  147. },
  148. paySuccess() {
  149. this.$util.pageTo({
  150. url: "/pages/callback/index",
  151. type: 2,
  152. query: {
  153. ...this.option,
  154. pageStatus: 3,
  155. payDiscountPrice: this.payCallData.discountAmount,
  156. payDiscountType: this.payCallData.discountType
  157. }
  158. });
  159. },
  160. payFail() {
  161. },
  162. balancePayFn() {
  163. if (this.shopUser.hasPayPwd == 0) {
  164. this.setPassModal = true;
  165. } else {
  166. this.passwordModal = true;
  167. }
  168. },
  169. passwordModalClick(e) {
  170. if (e.index === 0) {
  171. this.modalCancel();
  172. } else {
  173. this._balancePay();
  174. }
  175. },
  176. modalCancel() {
  177. this.passwordModal = false;
  178. this.form.payPassword = "";
  179. },
  180. // 暂未设置密码
  181. hideAlert() {
  182. this.$util.pageTo("/pages/user/password");
  183. },
  184. // 初始样式
  185. initClass(val) {
  186. switch (val) {
  187. case "1":
  188. this.pageTit = "待支付";
  189. this.contentClass = "awaitPayYe";
  190. break;
  191. case "2":
  192. this.pageTit = "待支付";
  193. this.contentClass = "awaitPayWx";
  194. break;
  195. case "3":
  196. this.pageTit = "支付成功";
  197. this.contentClass = "successPay";
  198. break;
  199. case "4":
  200. this.pageTit = "评价成功";
  201. this.contentClass = "successEval";
  202. break;
  203. case "5":
  204. this.pageTit = "支付成功";
  205. this.contentClass = "successPayCode";
  206. break;
  207. case "6":
  208. this.pageTit = "提交成功";
  209. this.contentClass = "registerMember";
  210. break;
  211. default:
  212. this.pageTit = "支付成功";
  213. this.contentClass = "awaitPayYe";
  214. break;
  215. }
  216. uni.setNavigationBarTitle({
  217. title: this.pageTit
  218. });
  219. }
  220. }
  221. };
  222. </script>
  223. <style lang="scss" scoped>
  224. .app-content {
  225. .callback-wrap {
  226. padding-top: 50upx;
  227. background-image: url("../../static/images/callback/bg.png");
  228. background-repeat: no-repeat;
  229. background-size: 100% auto;
  230. .callback-blo {
  231. width: 90%;
  232. margin: 0 auto;
  233. padding: 70upx 0;
  234. background-color: #fff;
  235. box-shadow: 2upx 2upx 16upx 0upx rgba(181, 181, 181, 0.29);
  236. border-radius: 10upx;
  237. text-align: center;
  238. // 使用icon
  239. .icon {
  240. .iconfont {
  241. font-size: 170upx;
  242. }
  243. }
  244. // 使用状态图片
  245. .status-img {
  246. width: 294upx;
  247. margin: 0 auto;
  248. }
  249. .call-btn-com {
  250. margin-top:60upx;
  251. @include disFlex(center, space-evenly);
  252. }
  253. // 一个按钮
  254. .call-one-btn {
  255. .button-com {
  256. width: 80%;
  257. padding-top: 22upx;
  258. padding-bottom: 22upx;
  259. font-size: 32upx;
  260. margin-top: 40upx;
  261. }
  262. }
  263. // 两个按钮
  264. .call-two-btn {
  265. .button-com {
  266. width: 40%;
  267. padding-top: 22upx;
  268. padding-bottom: 22upx;
  269. font-size: 32upx;
  270. }
  271. }
  272. }
  273. // 优惠券
  274. .coupon-wrap {
  275. width: 96%;
  276. margin: 52upx auto 0;
  277. position: relative;
  278. .qrcode-img {
  279. width: 170upx;
  280. height: 170upx;
  281. position: absolute;
  282. top: 40upx;
  283. right: 108upx;
  284. }
  285. }
  286. }
  287. }
  288. .awaitPayWx,
  289. .awaitPayYe {
  290. .status-text {
  291. margin-top: 22upx;
  292. margin-bottom: 52upx;
  293. color: #ffa92e;
  294. }
  295. .surplus {
  296. margin-top: 22upx;
  297. margin-bottom: 38upx;
  298. }
  299. .icon {
  300. .iconfont {
  301. color: #ffa92e;
  302. }
  303. }
  304. }
  305. .registerMember,
  306. .successPay,
  307. .successPayCode,
  308. .successEval {
  309. .status-text {
  310. color: #333;
  311. margin-top: 22upx;
  312. margin-bottom: 52upx;
  313. }
  314. }
  315. .registerMember {
  316. .call-back-wrap {
  317. .qr-code-img {
  318. width: 300upx;
  319. height: 300upx;
  320. margin: 20upx auto;
  321. img {
  322. height: 100%;
  323. }
  324. }
  325. .app-color-2 {
  326. font-size: 30upx;
  327. margin-bottom: 20upx;
  328. }
  329. }
  330. }
  331. </style>