codeSuccess.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <!--扫码成功-->
  2. <template>
  3. <view id="codeSuccess">
  4. <view class="top-title-box" v-if="pageShow">
  5. <img v-if="pageType" class="img-box-one" :src="imagesUrl('student/icon_dhli.png')">
  6. <img v-else class="img-box-two" :src="imagesUrl('student/icon_dhlp_dhcg.png')">
  7. <view class="text-p">{{pageType?'兑换礼品':'兑换成功'}}</view>
  8. </view>
  9. <view class="bottom-text-box" v-if="pageShow">
  10. <view class="min-text">
  11. <view>机器号</view>
  12. <view>{{mid}}</view>
  13. </view>
  14. <view class="min-text">
  15. <view>货道号</view>
  16. <view>{{sid}}</view>
  17. </view>
  18. <view class="min-text">
  19. <view>商品编号</view>
  20. <view>{{pid}}</view>
  21. </view>
  22. <view class="min-text">
  23. <view>积分</view>
  24. <view>{{pri}}</view>
  25. </view>
  26. </view>
  27. <view class="bottom-button-p" v-if="pageType&&pageShow"
  28. :class="pageType?'bottom-button-p-one':'bottom-button-p-two'" @click="clickButton">兑换</view>
  29. </view>
  30. </template>
  31. <script>
  32. import {
  33. exchangePoints
  34. } from '@/pages_student/api/index.js'
  35. export default {
  36. name: "codeSuccess",
  37. data() {
  38. return {
  39. mid: "",
  40. sid: "",
  41. pid: "",
  42. pri: "",
  43. pageType: true,
  44. pageShow: false,
  45. }
  46. },
  47. onLoad(option) {
  48. let self = this;
  49. if (option.q) {
  50. let text = decodeURIComponent(option.q)
  51. text = text.replace('"', '')
  52. text = text.replace('"', '')
  53. let list = text.split("?")[1].split("&");
  54. for (let i = 0; i < list.length; i++) {
  55. let newList = list[i].split("=");
  56. if (newList[0] == 'mid') {
  57. self.mid = newList[1];
  58. } else if (newList[0] == 'sid') {
  59. self.sid = newList[1];
  60. } else if (newList[0] == 'pid') {
  61. self.pid = newList[1];
  62. } else if (newList[0] == 'pri') {
  63. self.pri = newList[1];
  64. }
  65. }
  66. if (!uni.getStorageSync('token')) {
  67. uni.setStorageSync('mid', this.mid);
  68. uni.setStorageSync('sid', this.sid);
  69. uni.setStorageSync('pid', this.pid);
  70. uni.setStorageSync('pri', this.pri);
  71. uni.redirectTo({
  72. url: '/pages/views/login/login',
  73. });
  74. return
  75. }
  76. this.pageShow = true;
  77. } else {
  78. if (!uni.getStorageSync('token')) {
  79. uni.setStorageSync('mid', this.mid);
  80. uni.setStorageSync('sid', this.sid);
  81. uni.setStorageSync('pid', this.pid);
  82. uni.setStorageSync('pri', this.pri);
  83. uni.redirectTo({
  84. url: '/pages/views/login/login',
  85. });
  86. return
  87. }
  88. if (!uni.getStorageSync('mid')) {
  89. uni.redirectTo({
  90. url: '/pages/views/home/home',
  91. });
  92. return
  93. }
  94. this.mid = uni.getStorageSync('mid');
  95. this.sid = uni.getStorageSync('sid');
  96. this.pid = uni.getStorageSync('pid');
  97. this.pri = uni.getStorageSync('pri');
  98. uni.removeStorageSync('mid');
  99. uni.removeStorageSync('sid');
  100. uni.removeStorageSync('pid');
  101. uni.removeStorageSync('pri');
  102. this.pageShow = true;
  103. }
  104. },
  105. methods: {
  106. clickButton() {
  107. let self = this;
  108. if (self.pageType) {
  109. uni.showModal({
  110. title: '提示',
  111. content: '确认兑换吗?',
  112. success: function(res) {
  113. if (res.confirm) {
  114. self.exchangePoints();
  115. }
  116. }
  117. });
  118. }
  119. },
  120. async exchangePoints() {
  121. let self = this;
  122. let obj = {
  123. mid: this.mid,
  124. sid: this.sid,
  125. pid: this.pid,
  126. pri: this.pri,
  127. };
  128. const {
  129. data
  130. } = await exchangePoints(obj)
  131. if (data.code == 200) {
  132. uni.showToast({
  133. title: '兑换成功',
  134. mask: true,
  135. duration: 2000
  136. });
  137. this.pageType = false;
  138. } else {
  139. uni.showToast({
  140. title: data.msg,
  141. icon: "error",
  142. mask: true,
  143. duration: 2000
  144. });
  145. }
  146. }
  147. }
  148. }
  149. </script>
  150. <style lang="stylus" scoped>
  151. #codeSuccess {
  152. height: 100%;
  153. width: 100%;
  154. .top-title-box {
  155. overflow hidden;
  156. background #fff;
  157. height: 290rpx;
  158. border-bottom: 1rpx solid #dedede;
  159. .img-box-one {
  160. width: 150rpx;
  161. height: 135rpx;
  162. margin: 64rpx auto 0;
  163. }
  164. .img-box-two {
  165. width: 120rpx;
  166. height: 120rpx;
  167. margin: 64rpx auto 0;
  168. }
  169. .text-p {
  170. text-align center;
  171. line-height: 86rpx;
  172. font-size: 26rpx;
  173. }
  174. .num-p {
  175. text-align center;
  176. line-height: 64rpx;
  177. font-size: 36rpx;
  178. font-weigth: 700;
  179. }
  180. }
  181. .bottom-text-box {
  182. padding: 30rpx 100rpx;
  183. background #fff;
  184. .min-text {
  185. display: flex;
  186. view {
  187. font-size: 26rpx;
  188. line-height: 72rpx;
  189. }
  190. view:nth-child(1) {
  191. width: 192rpx;
  192. color: #999;
  193. }
  194. view:nth-child(2) {
  195. flex: 1;
  196. }
  197. }
  198. }
  199. .bottom-button-p {
  200. height: 70rpx;
  201. line-height: 70rpx;
  202. text-align center;
  203. border-radius: 10rpx;
  204. width: 300rpx;
  205. margin: 40rpx auto;
  206. }
  207. .bottom-button-p-one {
  208. color: #fff;
  209. background #00B68A
  210. }
  211. .bottom-button-p-two {
  212. color: #fff;
  213. background #dedede
  214. }
  215. }
  216. </style>