海南旅游项目 前端仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
3.4 KiB

4 years ago
4 years ago
4 years ago
  1. <template>
  2. <view class="lf-p-40 lf-w-100 lf-h-100 lf-row-center" style="height: 1200rpx;">
  3. <!-- <view class="lf-row-center lf-font-28">确认核销权限...</view> -->
  4. <button class="lf-m-t-30 cu-btn" v-if="haveVerfiy==false" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
  5. <text class="lf-font-32">确认核销</text>
  6. </button>
  7. <button class="lf-m-t-30 cu-btn1" v-else>
  8. <text class="lf-font-32">核销完成</text>
  9. </button>
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. data() {
  15. return {
  16. userInfo: '',
  17. loadOptions: '',
  18. haveVerfiy: false,
  19. ifProduct: false,
  20. strVerfiy: ''
  21. }
  22. },
  23. onLoad(options) {
  24. this.wxlogin();
  25. this.userInfo = uni.getStorageSync('userinfo');
  26. this.loadOptions = options.scene;
  27. this.strVerfiy = this.loadOptions.slice(2,this.loadOptions.length);
  28. var search_0$ = this.loadOptions.slice(0,2);
  29. if(search_0$ == 'hy') {
  30. this.ifProduct = true
  31. }else {
  32. this.ifProduct = false;
  33. }
  34. },
  35. methods: {
  36. wxlogin(){
  37. return new Promise((resolve, rejecj) => {
  38. uni.login({
  39. complete: result => {
  40. if(result.errMsg == 'login:ok'){
  41. let code = result.code;
  42. this.$http(this.API.API_WXLOGIN, { code }).then(res => {
  43. console.log("获得用户信息", res);
  44. uni.setStorageSync('userinfo', res.data);
  45. resolve(res.data);
  46. })
  47. }
  48. }
  49. })
  50. })
  51. },
  52. // 普通产品核销
  53. getPhoneNumber(event){
  54. if(this.userInfo.mobile == '') {
  55. if(event.detail.errMsg == 'getPhoneNumber:ok'){
  56. let encryptedData = event.detail.encryptedData;
  57. let iv = event.detail.iv;
  58. this.$http(this.API.API_WECHAT_SETPHONE, {
  59. encryptedData,
  60. iv,
  61. // token: userInfo.token // 已在公共参数传
  62. }).then(res => {
  63. this.$msg('更新成功', {icon: 'success'});
  64. uni.setStorageSync('userinfo', res.data);
  65. if(this.ifProduct == true) {
  66. this.$http(this.API.API_CONFIRMPRODUCT_CODE, {verify_code: this.strVerfiy}).then(res => {
  67. this.$msg('核销成功!');
  68. this.haveVerfiy = true
  69. }).catch(err => {
  70. this.$msg(JSON.stringify(err.msg))
  71. });
  72. }else {
  73. this.$http(this.API.API_CONFIRM_CODE, {verify_code: this.strVerfiy}).then(res => {
  74. this.$msg('核销成功!');
  75. this.haveVerfiy = true
  76. }).catch(err => {
  77. this.$msg(JSON.stringify(err.msg))
  78. });
  79. }
  80. })
  81. }
  82. }else {
  83. if(this.ifProduct == true) {
  84. this.$http(this.API.API_CONFIRMPRODUCT_CODE, {verify_code: this.strVerfiy}).then(res => {
  85. this.$msg('核销成功!');
  86. this.haveVerfiy = true
  87. }).catch(err => {
  88. this.$msg(JSON.stringify(err.msg))
  89. });
  90. }else {
  91. this.$http(this.API.API_CONFIRM_CODE, {verify_code: this.strVerfiy}).then(res => {
  92. this.$msg('核销成功!');
  93. this.haveVerfiy = true
  94. }).catch(err => {
  95. this.$msg(JSON.stringify(err.msg))
  96. });
  97. }
  98. }
  99. },
  100. }
  101. }
  102. </script>
  103. <style scoped>
  104. .cu-btn {
  105. width: 260rpx;
  106. height: 260rpx;
  107. border-radius: 50%;
  108. background-color: #1998FE;
  109. color: white;
  110. display: flex;
  111. justify-content: center;
  112. align-items: center;
  113. }
  114. .cu-btn1 {
  115. width: 260rpx;
  116. height: 260rpx;
  117. border-radius: 50%;
  118. background-color: #777;
  119. color: white;
  120. display: flex;
  121. justify-content: center;
  122. align-items: center;
  123. }
  124. </style>