index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <script setup>
  2. import { reactive, toRefs, onMounted, ref, unref } from "vue";
  3. import { Button, Toast } from "vant";
  4. import "vant/es/toast/style";
  5. import { getWxSign, getUser } from "@/api/api.js";
  6. import { useRouter, useRoute } from "vue-router";
  7. const router = useRouter();
  8. /**
  9. * 获取用户详情
  10. */
  11. const userInfo = ref({});
  12. const permissionList = ref([]);
  13. const getUse = async () => {
  14. // if (localStorage.getItem("Authorization")) {
  15. let res = await getUser({
  16. Token: "b0e0cb73b728d57c3895ec3817af1429",
  17. });
  18. console.log(res);
  19. if (res.Ret === 200) {
  20. userInfo.value = res.Data;
  21. permissionList.value = userInfo.value.Permission.split(",") || [];
  22. }
  23. // }
  24. };
  25. /**
  26. * 微信js_sdk
  27. */
  28. const wxconfig = async () => {
  29. const res = await getWxSign({ Url: window.location.href });
  30. if (res.Ret === 200) {
  31. wx.config({
  32. debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
  33. appId: res.Data.AppId, // 必填,公众号的唯一标识
  34. timestamp: res.Data.Timestamp, // 必填,生成签名的时间戳
  35. nonceStr: res.Data.NonceStr, // 必填,生成签名的随机串
  36. signature: res.Data.Signature, // 必填,签名
  37. jsApiList: ["hideAllNonBaseMenuItem", "onMenuShareTimeline"],
  38. openTagList: ["wx-open-launch-weapp"], // 可选,需要使用的开放标签列表,例如['wx-open-launch-app']
  39. });
  40. wx.ready(function () {
  41. wx.hideAllNonBaseMenuItem();
  42. });
  43. }
  44. };
  45. /**
  46. * 点击跳转推送规则
  47. */
  48. const goChangeTag = () => {
  49. router.push("/revamp");
  50. };
  51. /**
  52. * 点击跳转小程序
  53. */
  54. const handleLaunchFn = () => {
  55. console.log("sss");
  56. // alert('11')
  57. };
  58. const handleErrorFn = () => {
  59. // alert('ff')
  60. console.log("eee");
  61. };
  62. getUse();
  63. // wxconfig();
  64. onMounted(() => {
  65. document.title = "登录";
  66. var btn = document.getElementById("launch-btn");
  67. btn.addEventListener("launch", function (e) {
  68. console.log("success");
  69. });
  70. btn.addEventListener("error", function (e) {
  71. console.log("fail", e.detail);
  72. });
  73. btn.addEventListener("ready", function (e) {
  74. console.log("ready ");
  75. });
  76. });
  77. </script>
  78. <template>
  79. <div class="container-index">
  80. <div class="content">
  81. <p class="is-info" v-if="userInfo.HasPermission && userInfo.HasPermission != 3">您已登录成功!</p>
  82. <p class="is-info" v-else>暂无您的客户信息</p>
  83. <div class="synopsis">
  84. <p v-if="userInfo.HasPermission && userInfo.HasPermission != 3">我们将为您推送近期所有的研究更新与活动提醒</p>
  85. </div>
  86. <div class="personal-details">
  87. <div class="head-portrait">
  88. <img :src="userInfo.Headimgurl" v-if="userInfo.Headimgurl" />
  89. <img src="@/assets/img/init_imgurl.png" v-else />
  90. </div>
  91. <div class="details-item">
  92. <template v-if="userInfo.HasPermission == 1 || userInfo.HasPermission == 2">
  93. <p class="name">{{ userInfo.RealName }}</p>
  94. <p class="phone">{{ userInfo.Mobile }}</p>
  95. <p class="company">{{ userInfo.CompanyName }}</p>
  96. </template>
  97. </div>
  98. </div>
  99. <div class="authority">
  100. <template v-if="userInfo.HasPermission == 1">
  101. <div class="item" v-for="item in permissionList" :key="item">{{ item }}</div>
  102. </template>
  103. <template v-else-if="userInfo.HasPermission == 2">
  104. <div class="item">暂无权限</div>
  105. </template>
  106. </div>
  107. <div class="bottom-box">
  108. <p class="inform" v-if="userInfo.HasPermission == 1">您亦可在【推送规则】中更改您关注的赛道,让小助手更好地理解您的需求,为您降噪哦~</p>
  109. <p class="inform" v-else-if="userInfo.HasPermission == 2">当前无行业权限,可前往【查研观向】小程序申请开通试用权限</p>
  110. <p class="inform" v-else-if="userInfo.HasPermission == 3">请先前往【查研观向】小程序绑定您的联系方式并申请开通试用权限</p>
  111. <div class="bottom-btn" v-if="userInfo.HasPermission == 2" @click="goChangeTag">去更改</div>
  112. <div class="bottom-btn" v-else>
  113. 去小程序
  114. <wx-open-launch-weapp id="launch-btn" class="wx-app" username="gh_a9d3744e1072" path="pages/index/index.html">
  115. <div v-is="'script'" type="text/wxtag-template">
  116. <div class="btn">去小程序</div>
  117. </div>
  118. </wx-open-launch-weapp>
  119. </div>
  120. </div>
  121. </div>
  122. </div>
  123. </template>
  124. <style lang="scss" scoped>
  125. .container-index {
  126. width: 100%;
  127. height: 100vh;
  128. background: url("@/assets/img/bg_icon.png") no-repeat;
  129. background-size: 100% 100%;
  130. padding: 25% 15px 0;
  131. .content {
  132. width: 100%;
  133. height: 842px;
  134. padding: 60px 35px 0;
  135. background: url("@/assets/img/card_bg.png") no-repeat;
  136. background-size: 100% 100%;
  137. color: #fff;
  138. .is-info {
  139. font-size: 61px;
  140. font-weight: 500;
  141. }
  142. .synopsis {
  143. font-size: 28px;
  144. padding: 10px 0;
  145. height: 80px;
  146. }
  147. .personal-details {
  148. display: flex;
  149. .head-portrait {
  150. width: 126px;
  151. height: 126px;
  152. border-radius: 50%;
  153. overflow: hidden;
  154. img {
  155. width: 100%;
  156. height: 100%;
  157. }
  158. }
  159. .details-item {
  160. margin-left: 30px;
  161. font-size: 28px;
  162. .name {
  163. font-size: 34px;
  164. font-weight: 500;
  165. }
  166. .phone {
  167. padding: 10px 0 5px;
  168. }
  169. }
  170. }
  171. .authority {
  172. height: 238px;
  173. width: 105%;
  174. overflow: hidden;
  175. padding-top: 10px;
  176. .item {
  177. width: 148px;
  178. height: 34px;
  179. font-size: 24px;
  180. border-radius: 4px;
  181. display: inline-block;
  182. margin: 20px 20px 0 0;
  183. text-align: center;
  184. line-height: 32px;
  185. border: 1px solid #e5cfb1;
  186. font-weight: 400;
  187. color: #e5cfb1;
  188. }
  189. }
  190. .bottom-box {
  191. font-size: 28px;
  192. color: #fff;
  193. text-align: center;
  194. .inform {
  195. margin-bottom: 50px;
  196. }
  197. .bottom-btn {
  198. width: 337px;
  199. height: 62px;
  200. background: linear-gradient(180deg, #e5cfb1 0%, #caaf8b 100%);
  201. border-radius: 78px;
  202. margin: 0 auto;
  203. line-height: 62px;
  204. font-size: 32px;
  205. font-weight: 500;
  206. color: #3e3d3c;
  207. position: relative; // 相对定位
  208. z-index: 0;
  209. }
  210. .wx-app {
  211. position: absolute; // 绝对定位
  212. top: 0;
  213. left: 0;
  214. width: 100%;
  215. height: 100%;
  216. z-index: 100;
  217. opacity: 0;
  218. .btn {
  219. width: 100%;
  220. height: 100%;
  221. }
  222. }
  223. }
  224. }
  225. }
  226. </style>