index.vue 8.6 KB

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