codeSuccess.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. uni.redirectTo({
  75. url: '/pages/views/login/ssoLogin',
  76. });
  77. return
  78. }
  79. this.pageShow = true;
  80. } else {
  81. if (!uni.getStorageSync('token')) {
  82. uni.setStorageSync('mid', this.mid);
  83. uni.setStorageSync('sid', this.sid);
  84. uni.setStorageSync('pid', this.pid);
  85. uni.setStorageSync('pri', this.pri);
  86. // uni.redirectTo({
  87. // url: '/pages/views/login/login',
  88. // });
  89. uni.redirectTo({
  90. url: '/pages/views/login/ssoLogin',
  91. });
  92. return
  93. }
  94. if (!uni.getStorageSync('mid')) {
  95. uni.redirectTo({
  96. url: '/pages/views/home/home',
  97. });
  98. return
  99. }
  100. this.mid = uni.getStorageSync('mid');
  101. this.sid = uni.getStorageSync('sid');
  102. this.pid = uni.getStorageSync('pid');
  103. this.pri = uni.getStorageSync('pri');
  104. uni.removeStorageSync('mid');
  105. uni.removeStorageSync('sid');
  106. uni.removeStorageSync('pid');
  107. uni.removeStorageSync('pri');
  108. this.pageShow = true;
  109. }
  110. },
  111. methods: {
  112. clickButton() {
  113. let self = this;
  114. if (self.pageType) {
  115. uni.showModal({
  116. title: '提示',
  117. content: '确认兑换吗?',
  118. success: function(res) {
  119. if (res.confirm) {
  120. self.exchangePoints();
  121. }
  122. }
  123. });
  124. }
  125. },
  126. async exchangePoints() {
  127. let self = this;
  128. let obj = {
  129. mid: this.mid,
  130. sid: this.sid,
  131. pid: this.pid,
  132. pri: this.pri,
  133. };
  134. const {
  135. data
  136. } = await exchangePoints(obj)
  137. if (data.code == 200) {
  138. uni.showToast({
  139. title: '兑换成功',
  140. mask: true,
  141. duration: 2000
  142. });
  143. this.pageType = false;
  144. } else {
  145. uni.showToast({
  146. title: data.msg,
  147. icon: "error",
  148. mask: true,
  149. duration: 2000
  150. });
  151. }
  152. }
  153. }
  154. }
  155. </script>
  156. <style lang="stylus" scoped>
  157. #codeSuccess {
  158. height: 100%;
  159. width: 100%;
  160. .top-title-box {
  161. overflow hidden;
  162. background #fff;
  163. height: 290rpx;
  164. border-bottom: 1rpx solid #dedede;
  165. .img-box-one {
  166. width: 150rpx;
  167. height: 135rpx;
  168. margin: 64rpx auto 0;
  169. }
  170. .img-box-two {
  171. width: 120rpx;
  172. height: 120rpx;
  173. margin: 64rpx auto 0;
  174. }
  175. .text-p {
  176. text-align center;
  177. line-height: 86rpx;
  178. font-size: 26rpx;
  179. }
  180. .num-p {
  181. text-align center;
  182. line-height: 64rpx;
  183. font-size: 36rpx;
  184. font-weigth: 700;
  185. }
  186. }
  187. .bottom-text-box {
  188. padding: 30rpx 100rpx;
  189. background #fff;
  190. .min-text {
  191. display: flex;
  192. view {
  193. font-size: 26rpx;
  194. line-height: 72rpx;
  195. }
  196. view:nth-child(1) {
  197. width: 192rpx;
  198. color: #999;
  199. }
  200. view:nth-child(2) {
  201. flex: 1;
  202. }
  203. }
  204. }
  205. .bottom-button-p {
  206. height: 70rpx;
  207. line-height: 70rpx;
  208. text-align center;
  209. border-radius: 10rpx;
  210. width: 300rpx;
  211. margin: 40rpx auto;
  212. }
  213. .bottom-button-p-one {
  214. color: #fff;
  215. background #00B68A
  216. }
  217. .bottom-button-p-two {
  218. color: #fff;
  219. background #dedede
  220. }
  221. }
  222. </style>