index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <home-frame @toPath="toPath">
  3. <view class="main">
  4. <view class="one">
  5. <view class="one_1">
  6. <image class="image"
  7. :src="userInfo.logo_url&&userInfo.logo_url.length>0?userInfo.logo_url[0].url:''" mode="">
  8. </image>
  9. </view>
  10. <view class="one_2">
  11. <view class="name">
  12. {{userInfo.name||'暂无'}}
  13. </view>
  14. <view class="id">
  15. <uni-icons type="phone-filled" size="15" color="var(--rgbfff)"></uni-icons>
  16. :{{userInfo.phone||'暂无'}}
  17. </view>
  18. </view>
  19. <view class="one_3" v-if="!userInfo._id">
  20. <button size="mini" @tap="toLogin()">注册/登录</button>
  21. </view>
  22. </view>
  23. <view class="two">
  24. <view class="list" v-for="(item,index) in basicInfo.account_btn" :key="index" @tap="toCommon(item)">
  25. <image class="image" :src="item.img_url&&item.img_url.length>0?item.img_url[0].url:''" mode="">
  26. </image>
  27. <view class="name">
  28. {{item.name}}
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </home-frame>
  34. </template>
  35. <script>
  36. import homeFrame from "../components/home-frame.vue";
  37. export default {
  38. components: {
  39. homeFrame
  40. },
  41. data() {
  42. return {
  43. // 基本信息
  44. basicInfo: {},
  45. // 用户信息
  46. userInfo: {},
  47. };
  48. },
  49. onLoad() {
  50. },
  51. onShow() {
  52. const that = this;
  53. that.searchBasic();
  54. },
  55. methods: {
  56. searchBasic() {
  57. const that = this;
  58. uni.getStorage({
  59. key: 'basicInfo',
  60. success: (res) => {
  61. let data = res.data
  62. data.account_btn = data.account_btn.sort((a, b) => {
  63. return a.sort - b.sort
  64. });
  65. that.$set(that, `basicInfo`, data);
  66. that.search()
  67. }
  68. })
  69. },
  70. search() {
  71. const that = this;
  72. let user = {
  73. name: that.basicInfo.name,
  74. phone: 'test',
  75. logo_url: that.basicInfo.logo_url
  76. }
  77. uni.getStorage({
  78. key: 'token',
  79. success: async (res) => {
  80. let arr = that.$jwt(res.data);
  81. let aee = await that.$api(`user/${arr._id}`, 'GET');
  82. if (aee.errcode == '0') {
  83. user._id = aee.data._id;
  84. user.id = aee.data.id;
  85. user.phone = aee.data.phone;
  86. if (aee.data && aee.data.nick_name) user.name = aee.data.nick_name;
  87. if (aee.data && aee.data.logo_url) user.logo_url = aee.data.logo_url;
  88. }
  89. },
  90. fail: (err) => {
  91. console.log(err);
  92. }
  93. })
  94. that.$set(that, `userInfo`, user)
  95. },
  96. // 注册,登录
  97. toLogin() {
  98. uni.navigateTo({
  99. url: '/pagesAccount/login/index'
  100. })
  101. },
  102. // 功能按钮跳转
  103. toCommon(e) {
  104. const that = this;
  105. if (e.is_jump == '0') {
  106. if (e.nature == 'share') {
  107. console.log('分享');
  108. } else if (e.nature == 'logout') {
  109. uni.removeStorage({
  110. key: 'token',
  111. success: function(res) {
  112. uni.showToast({
  113. title: '退出登录成功',
  114. icon: 'none'
  115. })
  116. that.searchBasic()
  117. },
  118. fail: (err) => {
  119. close(err)
  120. }
  121. });
  122. }
  123. } else if (e.is_jump == '1') {
  124. that.toPath({
  125. type: e.type,
  126. route: e.route
  127. })
  128. }
  129. },
  130. // 跳转页面
  131. toPath(e) {
  132. let url = `/${e.route}`;
  133. if (e.type == '0') uni.navigateTo({
  134. url
  135. })
  136. else if (e.type == '1') uni.redirectTo({
  137. url
  138. })
  139. else if (e.type == '2') uni.reLaunch({
  140. url
  141. })
  142. else if (e.type == '3') uni.switchTab({
  143. url
  144. })
  145. }
  146. },
  147. };
  148. </script>
  149. <style lang="scss">
  150. .main {
  151. background-color: var(--rgb000);
  152. display: flex;
  153. flex-direction: column;
  154. width: 100vw;
  155. height: 92vh;
  156. overflow-y: auto;
  157. .one {
  158. display: flex;
  159. padding: 2vw;
  160. margin: 0 0 10px 0;
  161. .one_1 {
  162. width: 80px;
  163. height: 80px;
  164. overflow: hidden;
  165. margin: 0 2vw 0 0;
  166. .image {
  167. width: 100%;
  168. height: 80px;
  169. overflow: hidden;
  170. border-radius: 90%;
  171. }
  172. }
  173. .one_2 {
  174. flex-grow: 1;
  175. color: var(--rgbfff);
  176. font-size: 16px;
  177. font-weight: bold;
  178. padding: 2vw 0;
  179. overflow: hidden;
  180. .name {
  181. font-size: 18px;
  182. margin: 0 0 1vw 0;
  183. background: linear-gradient(to bottom right, var(--rgbfa4), var(--rgbfff));
  184. color: transparent;
  185. background-clip: text;
  186. -webkit-background-clip: text;
  187. }
  188. }
  189. .one_3 {
  190. padding: 4vw 0;
  191. overflow: hidden;
  192. button {
  193. background-color: var(--rgbfa4);
  194. color: var(--rgbfff);
  195. }
  196. }
  197. }
  198. .two {
  199. display: flex;
  200. // justify-content: space-around;
  201. flex-wrap: wrap;
  202. padding: 0 2vw;
  203. .list {
  204. width: 22%;
  205. height: 74px;
  206. margin: 0 10px 10px 0;
  207. text-align: center;
  208. background: linear-gradient(to bottom right, var(--rgb000), var(--rgbfa4));
  209. border: 1px solid var(--rgb111);
  210. border-radius: 5px;
  211. .image {
  212. width: 20px;
  213. height: 20px;
  214. margin: 3vw 0 2vw 0;
  215. }
  216. .name {
  217. color: var(--rgbfff);
  218. font-size: 14px;
  219. }
  220. }
  221. .list:nth-child(4n) {
  222. margin: 0 0 10px 0;
  223. }
  224. }
  225. }
  226. </style>