index.vue 6.5 KB

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