index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. <template>
  2. <view class="content">
  3. <top-title :titleValue="title" :btnTop="btnPos" style="width: 100%;"></top-title>
  4. <div class="self-inf">
  5. <div class="img-name-box" v-if="isAuth">
  6. <image :src="userHeadImg ? userHeadImg : '/static/auth-icon.png'" class="heade-img" mode="aspectFill"></image>
  7. <!-- <p class="nickname">{{ userNickName }}</p> -->
  8. <button @click="goAuthPage()" class="auth-btn">关联住房</button>
  9. </div>
  10. <view class="img-name-box" v-if="!isAuth">
  11. <image src="/static/auth-icon.png" class="heade-img" mode="aspectFill"></image>
  12. <button @click="goAuthPage()" class="auth-btn">立即登录</button>
  13. </view>
  14. <image class="bg-img" :src="swiperBackground" mode="aspectFill"></image>
  15. <image src="../../static/Intersect.svg" class="groove-img"></image>
  16. </div>
  17. <div class="options">
  18. <div v-for="(item, idx) in list" :key="idx" class="options-item" @click="goDetailFn(idx, item.url)" v-if="item.isShow">
  19. <div class="img-box">
  20. <img :src="item.icoin" alt="" class="options-item-img" />
  21. </div>
  22. <div class="options-item-name":class="{ fontGrey: idx == list.length - 1 }">
  23. {{ item.name }}
  24. </div>
  25. </div>
  26. </div>
  27. <foot-tabs :selectedIndex='1'></foot-tabs>
  28. </view>
  29. </template>
  30. <script>
  31. import md5 from "@/common/md5.js";
  32. import topTitle from '@/components/top-title/top-title.vue';
  33. import footTabs from '@/components/foot-tabs/footTabs.vue';
  34. export default {
  35. components: {
  36. 'foot-tabs': footTabs,
  37. 'top-title': topTitle
  38. },
  39. data() {
  40. return {
  41. title: "个人中心",
  42. isAuth: true,
  43. userHeadImg: "",
  44. userNickName: "",
  45. btnPos:uni.getMenuButtonBoundingClientRect().top + 6,
  46. list: [
  47. {
  48. icoin: "/static/selfCenter/sign.png",
  49. name: "供暖订单" ,
  50. url: "/pages/heatingPage/list",
  51. isShow:true,
  52. },
  53. {
  54. icoin: "/static/selfCenter/suggest.png",
  55. name: "我的报修" ,
  56. url: "/pages/selfCenter/my_activity",
  57. isShow:true,
  58. },
  59. // {
  60. // icoin: "/static/selfCenter/collection.png",
  61. // name: "我的收藏",
  62. // url: "/pages/selfCenter/collection",
  63. // isShow:true,
  64. // },
  65. // {
  66. // icoin: "/static/selfCenter/collection.png",
  67. // name: "工业经济指标",
  68. // url: "/pages/metrics/index",
  69. // isShow:true,
  70. // },
  71. {
  72. icoin: "/static/selfCenter/back.png",
  73. name: "退出登录" ,
  74. isShow:true,
  75. }
  76. ],
  77. swiperBackground: "/static/poster-bg.png",
  78. };
  79. },
  80. onLoad() {
  81. //this.getSwiperList();
  82. //this.$forceUpdate();
  83. },
  84. onShow() {
  85. // this.isAuth = getApp().globalData.isAuth;
  86. // if(this.isAuth){
  87. // this.userHeadImg = getApp().globalData.user_headUrl;
  88. // this.userNickName = getApp().globalData.user_name;
  89. // }
  90. //this.getUserInfo();
  91. },
  92. methods: {
  93. goAuthPage() {
  94. uni.navigateTo({
  95. url: "../auth/index",
  96. });
  97. },
  98. goDetailFn(index, url) {
  99. let that = this;
  100. if(!that.isAuth){
  101. uni.showToast({
  102. title: "您还没有登录授权",
  103. duration: 2500,
  104. icon: "none",
  105. });
  106. return;
  107. }
  108. switch (index) {
  109. case 0: //供暖订单
  110. uni.navigateTo({
  111. url,
  112. });
  113. break;
  114. case 1: //我的报修
  115. uni.navigateTo({
  116. url,
  117. });
  118. break;
  119. case 2: //退出登录
  120. uni.showModal({
  121. title: "确定退出登录吗?",
  122. success(res) {
  123. if (res.confirm) {
  124. that.loginOut();
  125. } else if (res.cancel) {
  126. console.log("用户点击取消");
  127. }
  128. },
  129. });
  130. break;
  131. }
  132. },
  133. loginOut() {
  134. let md5Sign = md5(
  135. "method=" +
  136. "user" +
  137. "&timestamp=" +
  138. getApp().globalData.globalTimestamp +
  139. "&secret=" +
  140. getApp().globalData.secret
  141. );
  142. let url =
  143. getApp().globalData.shareUrl +
  144. "api/api.php" +
  145. "?method=user&action=logout&timestamp=" +
  146. getApp().globalData.globalTimestamp +
  147. "&sign=" +
  148. md5Sign;
  149. uni.request({
  150. url: url,
  151. method: "POST",
  152. header: {
  153. "content-type": "application/x-www-form-urlencoded",
  154. },
  155. data: {
  156. openId: getApp().globalData.open_id,
  157. },
  158. success: (res) => {
  159. if (res.data.code === 200) {
  160. this.isAuth = false;
  161. getApp().globalData.isAuth = false;
  162. getApp().globalData.user_headUrl = "";
  163. getApp().globalData.user_name = "";
  164. getApp().globalData.user_phone = "";
  165. //this.list[2].isShow = false;
  166. //this.$forceUpdate();
  167. uni.showToast({
  168. title: "退出登录成功",
  169. duration: 2500,
  170. icon: "none",
  171. });
  172. }
  173. },
  174. fail: () => {
  175. console.log("连接失败");
  176. },
  177. });
  178. },
  179. getUserInfo() {
  180. let md5Sign = md5(
  181. "method=" +
  182. "user" +
  183. "&timestamp=" +
  184. getApp().globalData.globalTimestamp +
  185. "&secret=" +
  186. getApp().globalData.secret
  187. );
  188. let url =
  189. getApp().globalData.shareUrl +
  190. "api/api.php" +
  191. "?method=user&action=info_by_openid&timestamp=" +
  192. getApp().globalData.globalTimestamp +
  193. "&sign=" +
  194. md5Sign;
  195. uni.request({
  196. url: url,
  197. method: "POST",
  198. header: {
  199. "content-type": "application/x-www-form-urlencoded",
  200. },
  201. data: {
  202. openId: getApp().globalData.open_id,
  203. },
  204. success: (res) => {
  205. if (res.data.code === 200) {
  206. if (res.data.data.nickname) {
  207. this.isAuth = true;
  208. this.userHeadImg = res.data.data.headimg;
  209. this.userNickName = res.data.data.nickname;
  210. getApp().globalData.user_phone = res.data.data.phone;
  211. getApp().globalData.globalAuth = true;
  212. if(res.data.data.stat_user){
  213. this.list[3].isShow = true;
  214. }
  215. } else {
  216. this.isAuth = false;
  217. getApp().globalData.globalAuth = false;
  218. }
  219. }
  220. },
  221. fail: () => {
  222. console.log("连接失败");
  223. },
  224. });
  225. },
  226. getSwiperList() {
  227. let md5Sign = md5(
  228. "method=" +
  229. "common" +
  230. "&timestamp=" +
  231. getApp().globalData.globalTimestamp +
  232. "&secret=" +
  233. getApp().globalData.secret
  234. );
  235. let url =
  236. getApp().globalData.shareUrl +
  237. "api/api.php" +
  238. "?method=common&source=main_pics&action=list&timestamp=" +
  239. getApp().globalData.globalTimestamp +
  240. "&sign=" +
  241. md5Sign;
  242. uni.request({
  243. url: url,
  244. method: "POST",
  245. header: {
  246. "content-type": "application/x-www-form-urlencoded",
  247. },
  248. data: {
  249. order_by: "weight desc",
  250. s_status: 1,
  251. },
  252. success: (res) => {
  253. if (res.data.code === 200) {
  254. // this.swiperBackground = getApp().globalData.shareUrl + res.data.data.list[0].pic_path;
  255. }
  256. },
  257. fail: () => {
  258. console.log("连接失败");
  259. },
  260. });
  261. },
  262. },
  263. };
  264. </script>
  265. <style lang="scss" scoped>
  266. .content {
  267. display: flex;
  268. flex-direction: column;
  269. .self-inf {
  270. position: relative;
  271. height: 440rpx;
  272. width: 100%;
  273. display: flex;
  274. margin-bottom: 80rpx;
  275. border-radius: 0rpx 0rpx 100% 100%;
  276. .img-name-box {
  277. height: 200rpx;
  278. margin-top: 120rpx;
  279. display: flex;
  280. align-items: center;
  281. z-index: 99999;
  282. flex-direction: column;
  283. justify-content: center;
  284. .auth-btn {
  285. margin-left: 30rpx;
  286. margin-top: 20rpx;
  287. font-size: 24rpx;
  288. background-color: #02a7f0;
  289. color: #fff;
  290. }
  291. .heade-img {
  292. z-index: 1;
  293. width: 100rpx;
  294. height: 100rpx;
  295. border-radius: 50%;
  296. margin-left: 40rpx;
  297. }
  298. }
  299. .bg-img {
  300. z-index: -1;
  301. position: absolute;
  302. width: 100%;
  303. height: 100%;
  304. // border-radius: 0rpx 0rpx 70rpx 70rpx;
  305. }
  306. .groove-img {
  307. width: 100%;
  308. height: 100rpx;
  309. bottom: -22rpx;
  310. position: absolute;
  311. }
  312. .nickname {
  313. font-weight: 600;
  314. font-size: 28rpx;
  315. margin-left: 30rpx;
  316. margin-top: 20rpx;
  317. color: #ffffff;
  318. letter-spacing: 1rpx;
  319. }
  320. }
  321. .options {
  322. padding: 70rpx;
  323. z-index: 99;
  324. position: relative;
  325. top: -160rpx;
  326. .options-item {
  327. background-color: #fff;
  328. display: flex;
  329. box-shadow: 0px 4rpx 32rpx rgba(0, 0, 0, 0.1);
  330. border-radius: 32rpx;
  331. margin-top: 20px;
  332. height: 150rpx;
  333. align-items: center;
  334. .img-box {
  335. margin-left: 40rpx;
  336. .options-item-img {
  337. width: 56rpx;
  338. height: 56rpx;
  339. }
  340. }
  341. .options-item-name {
  342. margin-left: 40rpx;
  343. font-weight: 600;
  344. font-size: 30rpx;
  345. margin-bottom: 10rpx;
  346. }
  347. }
  348. }
  349. }
  350. .fontGrey {
  351. color: $uni-text-color-grey;
  352. }
  353. </style>