海南旅游项目 前端仓库
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.

109 lines
2.8 KiB

5 years ago
5 years ago
5 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(event.detail.errMsg == 'getPhoneNumber:ok'){
  55. let encryptedData = event.detail.encryptedData;
  56. let iv = event.detail.iv;
  57. this.$http(this.API.API_WECHAT_SETPHONE, {
  58. encryptedData,
  59. iv,
  60. // token: userInfo.token // 已在公共参数传
  61. }).then(res => {
  62. this.$msg('更新成功', {icon: 'success'});
  63. uni.setStorageSync('userinfo', res.data);
  64. if(this.ifProduct == true) {
  65. this.$http(this.API.API_CONFIRMPRODUCT_CODE, {verify_code: this.strVerfiy}).then(res => {
  66. this.$msg('核销成功!');
  67. this.haveVerfiy = true
  68. }).catch(err => {
  69. this.$msg(JSON.stringify(err.msg))
  70. });
  71. }else {
  72. this.$http(this.API.API_CONFIRM_CODE, {verify_code: this.strVerfiy}).then(res => {
  73. this.$msg('核销成功!');
  74. this.haveVerfiy = true
  75. }).catch(err => {
  76. this.$msg(JSON.stringify(err.msg))
  77. });
  78. }
  79. })
  80. }
  81. },
  82. }
  83. }
  84. </script>
  85. <style scoped>
  86. .cu-btn {
  87. width: 260rpx;
  88. height: 260rpx;
  89. border-radius: 50%;
  90. background-color: #1998FE;
  91. color: white;
  92. display: flex;
  93. justify-content: center;
  94. align-items: center;
  95. }
  96. .cu-btn1 {
  97. width: 260rpx;
  98. height: 260rpx;
  99. border-radius: 50%;
  100. background-color: #777;
  101. color: white;
  102. display: flex;
  103. justify-content: center;
  104. align-items: center;
  105. }
  106. </style>