codeSuccess.vue 5.9 KB

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