user.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <view>
  3. <view class="logo_box">
  4. <image src="https://kailin-mp.oss-cn-shenzhen.aliyuncs.com/static/logo2.jpg" class="logo_image"></image>
  5. </view>
  6. <button v-if="alloRequest" open-type="getPhoneNumber" @getphonenumber="getPhonenumber" class="get_phone">授权手机</button>
  7. <view v-if="!alloRequest" class="alter_info">抱歉,传入的参数有误,请联系您的客服</view>
  8. </view>
  9. </template>
  10. <script>
  11. export default {
  12. data() {
  13. return {
  14. requestParam: {
  15. code: "",
  16. kailin_uid: "",
  17. work_userid: "",
  18. },
  19. alloRequest: false,
  20. };
  21. },
  22. onLoad(param) {
  23. // 获取uid
  24. this.requestParam.kailin_uid = param.kailin_uid;
  25. // 跟进人员ID
  26. this.requestParam.work_userid = param.work_userid;
  27. },
  28. onShow() {
  29. // 判断是否存在参数
  30. if (this.requestParam.kailin_uid && this.requestParam.work_userid) {
  31. // 存在显示按钮
  32. this.alloRequest = true;
  33. }
  34. },
  35. methods: {
  36. getPhonenumber(re) {
  37. // 如果授权失败的话
  38. if (re.detail.errMsg != "getPhoneNumber:ok") {
  39. uni.showToast({
  40. icon: "error",
  41. title: "授权失败",
  42. });
  43. return;
  44. }
  45. // 获取授权码
  46. this.requestParam.code = re.detail.code;
  47. // 授权成功以后,调用登录
  48. this.$http.request("api/work_bind/custom", this.requestParam, "post").then((re) => {
  49. // 成功的话
  50. if (re.code == "success") {
  51. // 存储登录标识
  52. uni.setStorageSync("userLogin", re.data);
  53. // 跳转到页面
  54. uni.switchTab({ url: "/pages/user/index" });
  55. } else {
  56. uni.showToast({
  57. title: re.msg,
  58. icon: "none",
  59. });
  60. }
  61. });
  62. },
  63. },
  64. };
  65. </script>
  66. <style lang="less">
  67. .logo_box {
  68. display: block;
  69. margin: 0rpx auto;
  70. margin-top: 80rpx;
  71. .logo_image {
  72. width: 320rpx;
  73. height: 320rpx;
  74. display: block;
  75. margin: 0rpx auto;
  76. }
  77. }
  78. .get_phone {
  79. display: block;
  80. width: 180rpx;
  81. height: 60rpx;
  82. color: #ffffff;
  83. font-size: 28rpx;
  84. background: green;
  85. margin: 0rpx auto;
  86. line-height: 60rpx;
  87. margin-top: 160rpx;
  88. border-radius: 30rpx;
  89. border: 0rpx solid #dddddd;
  90. }
  91. .get_phone::after {
  92. border: 0rpx solid #dddddd;
  93. }
  94. .alter_info {
  95. display: block;
  96. color: #e03519;
  97. font-size: 20rpx;
  98. overflow: hidden;
  99. margin: 20rpx auto;
  100. background: #ffffff;
  101. line-height: 40rpx;
  102. padding: 35rpx 35rpx;
  103. text-align: center;
  104. }
  105. </style>