success.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <div class="wrapper">
  3. <div class="pay-wrapper">
  4. <div class="pay-money">
  5. ¥{{ Number(payPrice) | unitPrice }}
  6. </div>
  7. <div class="pay-btns">
  8. <div v-show="!from" @click="checkOrder">查看{{this.orderType == "RECHARGE" ? '余额' : '订单'}}</div>
  9. <div @click="navigateTo('/pages/tabbar/home/index', 'switch')">回到首页</div>
  10. </div>
  11. </div>
  12. <div class="pay-box">
  13. <div class="pay-tag-box">
  14. <h2>订单支付成功!</h2>
  15. <div class="pay-item">
  16. <div>
  17. 支付方式:
  18. </div>
  19. <div>{{paymentMethod | paymentTypeFilter}}</div>
  20. </div>
  21. </div>
  22. <!-- #ifdef MP-WEIXIN -->
  23. <div class="subscribe flex">
  24. <div>订阅订单状态</div>
  25. <div>
  26. <u-switch size="50" :disabled="checked" :active-color="activeColor" @change="changeStatus" v-model="checked"></u-switch>
  27. </div>
  28. </div>
  29. <!-- #endif -->
  30. </div>
  31. <div class="goods-recommend">--商品推荐--</div>
  32. <div class="goods-list">
  33. <div @click="handleClick(item)" class="goods-item" v-for="(item, item_index) in goodsList" :key="item_index">
  34. <div class="goods-img">
  35. <u-image :src="item.thumbnail" mode="aspectFill" height="350rpx" width="100%">
  36. <u-loading slot="loading"></u-loading>
  37. </u-image>
  38. </div>
  39. <div class="goods-desc">
  40. <div class="goods-title">
  41. {{ item.goodsName }}
  42. </div>
  43. <div class="goods-bottom">
  44. <div class="goods-price">¥{{ item.price | unitPrice }}</div>
  45. </div>
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. </template>
  51. <script>
  52. import { getGoodsList } from "@/api/goods.js";
  53. import { getWeChatMpMessage } from "@/api/message.js";
  54. export default {
  55. data() {
  56. return {
  57. checked: false,
  58. paymentMethod: "",
  59. from: "",
  60. payPrice: 0,
  61. goodsList: [],
  62. activeColor: this.$mainColor,
  63. params: {
  64. pageSize: 12,
  65. pageNumber: 1,
  66. },
  67. };
  68. },
  69. filters: {
  70. paymentTypeFilter(val) {
  71. switch (val) {
  72. case "WECHAT":
  73. return "微信";
  74. case "ALIPAY":
  75. return "支付宝";
  76. case "WALLET":
  77. return "余额支付";
  78. default:
  79. return "";
  80. }
  81. },
  82. },
  83. onLoad(options) {
  84. this.paymentMethod = options.paymentMethod || "";
  85. this.from = options.from || "";
  86. this.payPrice = options.payPrice || 0;
  87. this.orderType = options.orderType;
  88. //搜索商品
  89. this.initGoods();
  90. },
  91. methods: {
  92. checkOrder() {
  93. /**
  94. * 查看订单
  95. * 1.充值跳转到明细里面
  96. * 2.支付跳转到订单详情
  97. */
  98. if (this.orderType == "RECHARGE") {
  99. uni.reLaunch({
  100. url: `/pages/mine/deposit/operation`
  101. })
  102. } else {
  103. this.navigateTo("/pages/order/myOrder?status=0");
  104. }
  105. },
  106. changeStatus(val) {
  107. if (val) {
  108. this.sendMessage();
  109. }
  110. },
  111. async initGoods() {
  112. let goodsList = await getGoodsList(this.params);
  113. this.goodsList.push(...goodsList.data.result.content);
  114. },
  115. sendMessage() {
  116. //订阅消息
  117. //#ifdef MP-WEIXIN
  118. getWeChatMpMessage().then((res) => {
  119. var message = res.data.result;
  120. var templateid = message.map((item) => item.code);
  121. uni.requestSubscribeMessage({
  122. tmplIds: templateid,
  123. success: (res) => {
  124. for (let key in res) {
  125. if (res[key] == "reject") {
  126. this.checked = false;
  127. }
  128. }
  129. },
  130. fail: (res) => {
  131. uni.removeStorageSync("acceptSubscribeMessage");
  132. this.checked = false;
  133. },
  134. });
  135. });
  136. //#endif
  137. },
  138. handleClick(item) {
  139. uni.navigateTo({
  140. url: `/pages/product/goods?id=${item.id}&goodsId=${item.goodsId}`,
  141. });
  142. },
  143. navigateTo(url, type) {
  144. if (type === "switch") {
  145. uni.switchTab({
  146. url,
  147. });
  148. } else {
  149. uni.redirectTo({
  150. url,
  151. });
  152. }
  153. },
  154. },
  155. };
  156. </script>
  157. <style scoped lang="scss">
  158. .subscribe {
  159. justify-content: space-between;
  160. align-items: center;
  161. margin: 0 auto 40rpx auto;
  162. padding: 0 20rpx 20rpx;
  163. width: 80%;
  164. }
  165. .pay-btns {
  166. display: flex;
  167. width: 50%;
  168. justify-content: space-between;
  169. margin: 0 auto;
  170. color: #fff;
  171. > div {
  172. padding: 6px 12px;
  173. border: 1px solid #fff;
  174. border-radius: 100px;
  175. }
  176. }
  177. .pay-money {
  178. line-height: 1;
  179. font-size: 50rpx;
  180. color: #fff;
  181. margin-bottom: 100rpx;
  182. }
  183. .pay-item {
  184. font-weight: bold;
  185. margin: 32rpx 0;
  186. display: flex;
  187. justify-content: space-between;
  188. font-size: 24rpx;
  189. color: rgba($color: $main-color, $alpha: 0.8);
  190. }
  191. .pay-box {
  192. overflow: hidden;
  193. }
  194. .pay-tag-box {
  195. width: 80%;
  196. margin: 80rpx auto 40rpx auto;
  197. padding: 20rpx;
  198. border-radius: 20rpx;
  199. background: rgba($color: $main-color, $alpha: 0.2);
  200. > h2 {
  201. margin-top: 20rpx;
  202. font-size: 40rpx;
  203. color: $main-color;
  204. }
  205. }
  206. .pay-wrapper {
  207. background-image: linear-gradient(90deg, #fa123b, #ff6b35, #ff9f28, #ffcc03);
  208. height: 480rpx;
  209. position: relative;
  210. display: flex;
  211. align-items: center;
  212. justify-content: center;
  213. flex-direction: column;
  214. }
  215. .pay-box {
  216. transform: translateY(-100rpx);
  217. width: 100%;
  218. background: #fff;
  219. border-top-right-radius: 100rpx;
  220. }
  221. /**商品代码 */
  222. $w_94: 94%;
  223. .goods-recommend {
  224. background: #f7f7f7;
  225. height: 100rpx;
  226. line-height: 100rpx;
  227. text-align: center;
  228. font-size: 30rpx;
  229. font-weight: bold;
  230. }
  231. .goods-list {
  232. display: flex;
  233. flex-wrap: wrap;
  234. background: #f7f7f7;
  235. }
  236. .goods-item {
  237. width: 50%;
  238. margin-bottom: 10px;
  239. border-radius: 0.4em;
  240. overflow: hidden;
  241. }
  242. .goods-img {
  243. position: relative;
  244. margin: 0 auto;
  245. // width: 158px;
  246. width: $w_94;
  247. height: 350rpx;
  248. border-top-left-radius: 20rpx;
  249. border-top-right-radius: 20rpx;
  250. overflow: hidden;
  251. > img {
  252. width: 100%;
  253. height: 100%;
  254. }
  255. }
  256. .goods-desc {
  257. border-bottom-left-radius: 20rpx;
  258. border-bottom-right-radius: 20rpx;
  259. width: $w_94;
  260. background: #fff;
  261. padding: 8rpx 0 8rpx 8rpx;
  262. margin: 0 auto;
  263. > .goods-title {
  264. font-size: 12px;
  265. height: 70rpx;
  266. display: -webkit-box;
  267. font-weight: 500;
  268. -webkit-box-orient: vertical;
  269. -webkit-line-clamp: 2;
  270. overflow: hidden;
  271. }
  272. > .goods-bottom {
  273. display: flex;
  274. font-weight: bold;
  275. > .goods-price {
  276. line-height: 2;
  277. color: $main-color;
  278. }
  279. }
  280. }
  281. .goods-icon {
  282. right: 10rpx;
  283. top: 10rpx;
  284. position: absolute;
  285. }
  286. </style>