index.vue 6.1 KB

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