index.vue 6.7 KB

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