index.vue 8.1 KB

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