result.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <view class="container">
  3. <view class="success">
  4. <view v-if="isSuccess" class="result">
  5. <image class="icon" src='/static/pay/success.png'></image>
  6. <text class="text" v-if="message && message != undefined">{{ message }}</text>
  7. <text class="text" v-if="!message || message == undefined">恭喜,支付成功!</text>
  8. </view>
  9. <view v-if="!isSuccess" class="result">
  10. <image class="icon" src='/static/pay/fail.png'></image>
  11. <text class="text" v-if="message && message != undefined" style="color:#888888;">支付失败:{{ message }}</text>
  12. <text class="text" v-if="!message || message == undefined" style="color:#888888;">哎呀,支付失败啦~</text>
  13. </view>
  14. <view class="options">
  15. <view class="to-home" @click="toHome()"><text class="iconfont icon-home"></text>返回首页</view>
  16. <view class="to-order" @click="toOrderInfo()"><text class="iconfont icon-form"></text>查看订单</view>
  17. </view>
  18. </view>
  19. <block>
  20. <Goods ref="mescrollItem" :itemStyle="goodsStyle" :params="goodsParams"/>
  21. </block>
  22. </view>
  23. </template>
  24. <script>
  25. import Goods from '@/components/page/goods'
  26. import * as Api from '@/api/page'
  27. import * as OrderApi from '@/api/order'
  28. import * as MessageApi from '@/api/message'
  29. import MescrollCompMixin from "@/components/mescroll-uni/mixins/mescroll-comp.js"
  30. export default {
  31. mixins: [MescrollCompMixin],
  32. components: {
  33. Goods
  34. },
  35. data() {
  36. return {
  37. orderId: 0,
  38. orderInfo: null,
  39. isLoading: true,
  40. isSuccess: false,
  41. message: '',
  42. goodsStyle: {
  43. "background": "#F6F6F6",
  44. "display": "list",
  45. "column": 1,
  46. "show": ["goodsName", "goodsPrice", "linePrice", "sellingPoint", "goodsSales"]
  47. },
  48. goodsParams: {
  49. "source": "auto",
  50. "auto": {
  51. "category": 0,
  52. "goodsSort": "all",
  53. "showNum": 40
  54. }
  55. }
  56. }
  57. },
  58. /**
  59. * 生命周期函数--监听页面加载
  60. */
  61. onLoad(options) {
  62. // 当前页面参数
  63. this.orderId = options.orderId ? options.orderId : 0;
  64. this.message = options.message ? options.message : '';
  65. this.getOrderDetail();
  66. },
  67. methods: {
  68. /**
  69. * 去首页
  70. * */
  71. toHome() {
  72. const app = this
  73. // #ifdef MP-WEIXIN
  74. MessageApi.getSubTemplate({keys: "orderCreated,deliverGoods"}).then(result => {
  75. const templateIds = result.data
  76. wx.requestSubscribeMessage({tmplIds: templateIds,
  77. success(res) {
  78. console.log("调用成功!")
  79. }, fail(res) {
  80. console.log("调用失败:", res)
  81. }, complete() {
  82. app.$navTo('pages/index/index')
  83. }
  84. })
  85. })
  86. // #endif
  87. // #ifndef MP-WEIXIN
  88. app.$navTo('pages/index/index')
  89. // #endif
  90. },
  91. /**
  92. * 去订单详情
  93. * */
  94. toOrderInfo() {
  95. const app = this
  96. // #ifdef MP-WEIXIN
  97. MessageApi.getSubTemplate({keys: "orderCreated,deliverGoods"}).then(result => {
  98. const templateIds = result.data
  99. wx.requestSubscribeMessage({tmplIds: templateIds,
  100. success(res) {
  101. console.log("调用成功!")
  102. }, fail(res) {
  103. console.log("调用失败:", res)
  104. }, complete() {
  105. app.$navTo('pages/order/detail?orderId=' + app.orderId)
  106. }
  107. })
  108. })
  109. // #endif
  110. // #ifndef MP-WEIXIN
  111. app.$navTo('pages/order/detail?orderId=' + app.orderId)
  112. // #endif
  113. },
  114. getOrderDetail() {
  115. const app = this
  116. app.isLoading = true
  117. const tableId = uni.getStorageSync("tableId") ? uni.getStorageSync("tableId") : 0;
  118. if (tableId <= 0) {
  119. OrderApi.detail(app.orderId)
  120. .then(result => {
  121. app.isSuccess = result.data.payStatus === 'B' ? true : false;
  122. app.isLoading = false;
  123. })
  124. } else {
  125. app.isSuccess = true;
  126. app.isLoading = false;
  127. uni.setStorageSync("tableId", 0);
  128. uni.setStorageSync("orderId", 0);
  129. }
  130. }
  131. }
  132. }
  133. </script>
  134. <style lang="scss" scoped>
  135. .success {
  136. width: 100%;
  137. text-align: center;
  138. margin-top: 60rpx;
  139. margin-bottom: 80rpx;
  140. .result {
  141. font-size: 35rpx;
  142. text-align: center;
  143. padding: 10rpx;
  144. height: 70rpx;
  145. .icon {
  146. width: 55rpx;
  147. height: 55rpx;
  148. display: inline-block;
  149. box-sizing: border-box;
  150. vertical-align: middle;
  151. }
  152. .text {
  153. text-align: center;
  154. height: 100%;
  155. display: inline-block;
  156. box-sizing: border-box;
  157. vertical-align: middle;
  158. color: #00B83F;
  159. margin-left: 10rpx;
  160. font-weight: bold;
  161. }
  162. }
  163. .options {
  164. margin-top: 0rpx;
  165. text-align: center;
  166. display: flex;
  167. align-items: center;
  168. flex-direction:row;
  169. padding: 50rpx 100rpx 60rpx 100rpx;
  170. .to-home,.to-order {
  171. margin: 0 auto;
  172. font-size: 28rpx;
  173. height: 72rpx;
  174. line-height: 72rpx;
  175. text-align: center;
  176. color: #888;
  177. border-radius: 72rpx;
  178. width: 240rpx;
  179. background: #fff;
  180. border: solid 1rpx #888;
  181. float: left;
  182. }
  183. .iconfont {
  184. font-weight: bold;
  185. margin-right: 5rpx;
  186. }
  187. }
  188. }
  189. .attention {
  190. width: 100%;
  191. text-align: center;
  192. margin-top: 14rpx;
  193. }
  194. </style>