index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <view>
  3. <view class="payment-status">
  4. <!--失败时: 用icon-iconfontguanbi fail替换icon-duihao2 bg-color-->
  5. <view
  6. class="iconfont icons icon-success bg-color"
  7. v-if="order_pay_info.paid || order_pay_info.payType == 'offline'"
  8. ></view>
  9. <view class="iconfont icons fail-status icon-fail" v-else></view>
  10. <!-- 失败时:订单支付失败 -->
  11. <view class="status" v-if="order_pay_info.payType != 'offline'">{{
  12. order_pay_info.paid ? "订单支付成功" : "订单支付失败"
  13. }}</view>
  14. <view class="status" v-else>订单创建成功</view>
  15. <view class="wrapper">
  16. <view class="item acea-row row-between-wrapper">
  17. <view>订单编号</view>
  18. <view class="itemCom">{{ order_pay_info.orderId }}</view>
  19. </view>
  20. <view class="item acea-row row-between-wrapper">
  21. <view>下单时间</view>
  22. <view class="itemCom">{{
  23. order_pay_info.createTime ? order_pay_info.createTime : "-"
  24. }}</view>
  25. </view>
  26. <view class="item acea-row row-between-wrapper">
  27. <view>支付方式</view>
  28. <block v-if="order_pay_info.mallType === 0">
  29. <!-- <view class="itemCom" v-if="order_pay_info.payType == 'weixin'"
  30. >微信支付</view
  31. > -->
  32. <view class="itemCom" v-if="order_pay_info.payType == 'yue'"
  33. >余额支付</view
  34. >
  35. <view
  36. class="itemCom"
  37. v-else-if="order_pay_info.payType == 'offline'"
  38. >线下支付</view
  39. >
  40. <!-- <view class="itemCom" v-else-if="order_pay_info.payType == 'alipay'"
  41. >支付宝支付</view
  42. > -->
  43. </block>
  44. <view class="itemCom" v-else>贝币支付</view>
  45. </view>
  46. <view class="item acea-row row-between-wrapper">
  47. <view>支付金额</view>
  48. <view class="itemCom" v-if="order_pay_info.mallType === 0">{{
  49. order_pay_info.payPrice
  50. }}</view>
  51. <view class="itemCom" v-else>{{ order_pay_info.totalPrice }}</view>
  52. </view>
  53. <!--失败时加上这个 -->
  54. <view
  55. class="item acea-row row-between-wrapper"
  56. v-if="order_pay_info.paid == 0 && order_pay_info.payType != 'offline'"
  57. >
  58. <view>失败原因</view>
  59. <!-- <view class="itemCom">{{ status == 2 ? "取消支付" : msg }}</view> -->
  60. <view class="itemCom">{{ msg }}</view>
  61. </view>
  62. </view>
  63. <!--失败时: 重新购买 -->
  64. <view @tap="goOrderDetails">
  65. <button formType="submit" class="returnBnt bg-color" hover-class="none">
  66. 查看订单
  67. </button>
  68. </view>
  69. <button
  70. @click="goMallIndex"
  71. class="returnBnt cart-color"
  72. formType="submit"
  73. hover-class="none"
  74. >
  75. 返回商城
  76. </button>
  77. </view>
  78. </view>
  79. </template>
  80. <script setup>
  81. import { ref, computed, watch } from "vue";
  82. import { useAppStore } from "@/stores/app.js";
  83. import { onLoad, onBackPress } from "@dcloudio/uni-app";
  84. import { getOrderDetail } from "@/api/order.js";
  85. import { openOrderSubscribe } from "@/utils/SubscribeMessage.js";
  86. import { toLogin } from "@/libs/login.js";
  87. import { usePayment } from "@/hooks/usePayment";
  88. import { addRecommenderRole, getJoinTeamUserRoles } from "@/utils/util";
  89. const appStore = useAppStore();
  90. const { paymentResult } = usePayment();
  91. const orderId = ref("");
  92. const order_pay_info = ref({
  93. paid: 1,
  94. _status: {},
  95. });
  96. const isAuto = ref(false);
  97. const isShowAuth = ref(false);
  98. const status = ref(0);
  99. const msg = ref("");
  100. const join_roles = ref([]);
  101. function getOrderPayInfo() {
  102. uni.showLoading({
  103. title: "正在加载中",
  104. });
  105. getOrderDetail(orderId.value)
  106. .then((res) => {
  107. uni.hideLoading();
  108. order_pay_info.value = res.data;
  109. uni.setNavigationBarTitle({
  110. title: res.data.paid ? "支付成功" : "支付失败",
  111. });
  112. // 自动成为推荐官
  113. if (res.data.paid && !join_roles.value.includes("推荐官")) {
  114. addRecommenderRole();
  115. }
  116. })
  117. .catch(() => {
  118. uni.hideLoading();
  119. });
  120. }
  121. function goMallIndex() {
  122. console.log("mallType", order_pay_info.value.mallType);
  123. uni.navigateTo({
  124. url: "/pages/index/index",
  125. });
  126. }
  127. onBackPress((options) => {
  128. if (order_pay_info.value.mallType === 1) {
  129. uni.navigateTo({
  130. url: "/pages/index/index",
  131. });
  132. return true;
  133. }
  134. const productId = order_pay_info.value.orderInfoList?.[0].productId || "";
  135. if (productId) {
  136. uni.reLaunch({
  137. url: `/pages/goods_details/index?id=${productId}`,
  138. });
  139. return true;
  140. }
  141. uni.reLaunch({
  142. url: `/pages/index/index`,
  143. });
  144. return true;
  145. });
  146. function goOrderDetails() {
  147. uni.navigateTo({
  148. url: "/pages/order_details/index?order_id=" + orderId.value,
  149. });
  150. }
  151. // 授权回调
  152. function onLoadFun() {
  153. getOrderPayInfo();
  154. }
  155. // 监听登录状态
  156. watch(
  157. () => appStore.isLogin,
  158. (newV) => {
  159. if (newV) {
  160. getOrderPayInfo();
  161. }
  162. }
  163. );
  164. // 页面加载
  165. onLoad(async (options) => {
  166. console.log({ options });
  167. if (!options.order_id) {
  168. return uni.showToast({
  169. title: "缺少参数无法查看订单支付状态",
  170. icon: "none",
  171. });
  172. }
  173. orderId.value = options.order_id;
  174. status.value = options.status || 0;
  175. msg.value = options.msg || "";
  176. join_roles.value = await getJoinTeamUserRoles();
  177. if (appStore.isLogin) {
  178. getOrderPayInfo();
  179. } else {
  180. toLogin();
  181. }
  182. });
  183. </script>
  184. <style lang="scss" scoped>
  185. .fail-status {
  186. background-color: #999 !important;
  187. text-shadow: none !important;
  188. }
  189. .payment-status {
  190. background-color: #fff;
  191. margin: 120rpx 30rpx 0 30rpx;
  192. border-radius: 10rpx;
  193. padding: 1rpx 0 28rpx 0;
  194. }
  195. .payment-status .icons {
  196. font-size: 70rpx;
  197. width: 140rpx;
  198. height: 140rpx;
  199. border-radius: 50%;
  200. color: #fff;
  201. text-align: center;
  202. line-height: 140rpx;
  203. // text-shadow: 0px 4px 0px #df1e14;
  204. border: 6rpx solid #f5f5f5;
  205. margin: -76rpx auto 0 auto;
  206. background-color: #999;
  207. }
  208. .payment-status .iconfont {
  209. font-size: 75rpx;
  210. width: 140rpx;
  211. height: 140rpx;
  212. border-radius: 50%;
  213. color: #fff;
  214. text-align: center;
  215. line-height: 140rpx;
  216. // text-shadow: 0px 4px 0px #df1e14;
  217. border: 6rpx solid #f5f5f5;
  218. margin: -76rpx auto 0 auto;
  219. background-color: #999;
  220. background-color: $theme-color;
  221. }
  222. .payment-status .iconfont.fail {
  223. text-shadow: 0px 4px 0px #7a7a7a;
  224. }
  225. .payment-status .status {
  226. font-size: 32rpx;
  227. font-weight: bold;
  228. text-align: center;
  229. margin: 25rpx 0 37rpx 0;
  230. }
  231. .payment-status .wrapper {
  232. border: 1rpx solid #eee;
  233. margin: 0 30rpx 47rpx 30rpx;
  234. padding: 35rpx 0;
  235. border-left: 0;
  236. border-right: 0;
  237. }
  238. .payment-status .wrapper .item {
  239. font-size: 28rpx;
  240. color: #282828;
  241. }
  242. .payment-status .wrapper .item ~ .item {
  243. margin-top: 20rpx;
  244. }
  245. .payment-status .wrapper .item .itemCom {
  246. color: #666;
  247. }
  248. .payment-status .returnBnt {
  249. width: 630rpx;
  250. height: 86rpx;
  251. border-radius: 50rpx;
  252. color: #fff;
  253. font-size: 30rpx;
  254. text-align: center;
  255. line-height: 86rpx;
  256. margin: 0 auto 20rpx auto;
  257. }
  258. </style>