codeSuccess.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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. creditAppletExchangePoints,examPointsRecordExchangePoints
  34. } from '@/pages_basics/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.creditAppletExchangePoints();
  115. }
  116. }
  117. });
  118. }
  119. },
  120. async creditAppletExchangePoints() {
  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 creditAppletExchangePoints(obj)
  131. } = await examPointsRecordExchangePoints(obj)
  132. if (data.code == 200) {
  133. uni.showToast({
  134. title: '兑换成功',
  135. mask: true,
  136. duration: 2000
  137. });
  138. this.pageType = false;
  139. } else {
  140. uni.showToast({
  141. title: data.msg,
  142. icon: "error",
  143. mask: true,
  144. duration: 2000
  145. });
  146. }
  147. }
  148. }
  149. }
  150. </script>
  151. <style lang="stylus" scoped>
  152. #codeSuccess {
  153. height: 100%;
  154. width: 100%;
  155. .top-title-box {
  156. overflow hidden;
  157. background #fff;
  158. height: 290rpx;
  159. border-bottom: 1rpx solid #dedede;
  160. .img-box-one {
  161. width: 150rpx;
  162. height: 135rpx;
  163. margin: 64rpx auto 0;
  164. }
  165. .img-box-two {
  166. width: 120rpx;
  167. height: 120rpx;
  168. margin: 64rpx auto 0;
  169. }
  170. .text-p {
  171. text-align center;
  172. line-height: 86rpx;
  173. font-size: 26rpx;
  174. }
  175. .num-p {
  176. text-align center;
  177. line-height: 64rpx;
  178. font-size: 36rpx;
  179. font-weigth: 700;
  180. }
  181. }
  182. .bottom-text-box {
  183. padding: 30rpx 100rpx;
  184. background #fff;
  185. .min-text {
  186. display: flex;
  187. view {
  188. font-size: 26rpx;
  189. line-height: 72rpx;
  190. }
  191. view:nth-child(1) {
  192. width: 192rpx;
  193. color: #999;
  194. }
  195. view:nth-child(2) {
  196. flex: 1;
  197. }
  198. }
  199. }
  200. .bottom-button-p {
  201. height: 70rpx;
  202. line-height: 70rpx;
  203. text-align center;
  204. border-radius: 10rpx;
  205. width: 300rpx;
  206. margin: 40rpx auto;
  207. }
  208. .bottom-button-p-one {
  209. color: #fff;
  210. background #00B68A
  211. }
  212. .bottom-button-p-two {
  213. color: #fff;
  214. background #dedede
  215. }
  216. }
  217. </style>