follow.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <view>
  3. <view class="add_follow" :style="safeAreaHeight">
  4. <view class="close_area"></view>
  5. <view class="info_alter">
  6. <text v-show="follow_linkurl">{{ clickTitle }}</text>
  7. <text v-show="!follow_linkurl">{{ longTapTitle }}</text>
  8. </view>
  9. <view v-if="followQrcode" class="qr_code_area" @click="followLinkurl">
  10. <image :src="followQrcode" class="qr_code" mode="" show-menu-by-longpress> </image>
  11. </view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. data() {
  18. return {
  19. clickTitle:"点击二维码添加客服",
  20. longTapTitle:"长按二维码添加客服",
  21. followQrcode:"",
  22. follow_linkurl:"",
  23. safeAreaHeight:{}
  24. }
  25. },
  26. onLoad() {
  27. let safeArea = uni.getWindowInfo().safeArea;
  28. this.safeAreaHeight = {height: safeArea.height + 'px'};
  29. },
  30. onShow() {
  31. // 登录提示
  32. if( !this.$checkAccess.alterLogin() ) return ;
  33. // 判断数据
  34. this.$http.request('api/custom/get_info').then((callback)=>{
  35. if( callback.code == 'success' ){
  36. if( !callback.data.userpic ) callback.data.userpic = "../../static/icon/doctor.png";
  37. // 存储登录标识
  38. uni.setStorageSync('userInfo',callback.data);
  39. }
  40. });
  41. this.openAddFollow();
  42. },
  43. methods: {
  44. // 客服显示
  45. openAddFollow(){
  46. // 返回结果
  47. this.followQrcode = this.$checkAccess.getFollowQrcode();
  48. // 返回结果
  49. this.follow_linkurl = this.$checkAccess.getFollowLinkUrl();
  50. },
  51. followLinkurl() {
  52. // 获取登录标识
  53. let userInfo = uni.getStorageSync("userInfo");
  54. // 如果不存在的话
  55. if (!userInfo) return "";
  56. // 未添加好友
  57. if (!userInfo.follow_linkurl) return "";
  58. // 获取Url
  59. let url = userInfo.follow_linkurl;
  60. // 没有路径,不跳转
  61. if (!url) return;
  62. // 判断是不是小程序链接
  63. if (url.includes("http")) {
  64. // 转码
  65. let link_url = encodeURIComponent(url);
  66. // 跳转到webview
  67. uni.redirectTo({
  68. url: `/pages/webview/index?link_url=${link_url}`,
  69. });
  70. } else {
  71. // 跳转到webview
  72. uni.navigateTo({
  73. url: url,
  74. });
  75. }
  76. },
  77. }
  78. }
  79. </script>
  80. <style lang="less">
  81. .add_follow{
  82. display: block;
  83. color: #FFFFFF;
  84. width: 750rpx;
  85. height: 900rpx;
  86. margin: 0rpx auto;
  87. font-size: 26rpx;
  88. background: linear-gradient(to bottom, #ff0091 0%, #2c82ff 100%);
  89. .close_area{
  90. height: 80rpx;
  91. display: block;
  92. line-height: 30rpx;
  93. }
  94. .info_alter{
  95. display: block;
  96. height: 100rpx;
  97. font-size: 42rpx;
  98. font-weight: bold;
  99. text-align: center;
  100. line-height: 100rpx;
  101. }
  102. .qr_code_area{
  103. display: block;
  104. width: 300rpx;
  105. height: 300rpx;
  106. margin: 120rpx auto;
  107. .qr_code{
  108. float: left;
  109. width: 300rpx;
  110. height: 300rpx;
  111. }
  112. }
  113. }
  114. </style>