selfInfo.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <view class="content" :style="{height:nowHeight}">
  3. <view class="self-title-box">
  4. <image :src='userHeadUrl' mode="aspectFit"></image>
  5. <text>{{userName}}</text>
  6. </view>
  7. <button class="login-button-pos" v-if="isShowAuthBtn" open-type="getUserInfo" @getuserinfo="getUserInfo">未授权,请点击获取信息</button>
  8. <view class="self-search-box">
  9. <view class="search-content">
  10. <view class="search-content-value">{{userTime}}</view>
  11. <view class="search-content-text">剩余查询次数(次)</view>
  12. </view>
  13. <view class="line"></view>
  14. <view class="search-content">
  15. <view class="search-content-value">{{userTotalTime}}</view>
  16. <view class="search-content-text">总查询次数(次)</view>
  17. </view>
  18. </view>
  19. <view class="self-pay-box">
  20. <view class="search-content">
  21. <view class="search-content-value" style="color:#000;font-size: 38upx;margin-left: -11%;">查询套餐</view>
  22. <view class="search-content-text">限时优惠进行中</view>
  23. </view>
  24. <view class="search-content" style="width: 33%;height: 180rpx;" @click.stop="goPayPage()">
  25. <image src="../../static/payIcon.png" mode=""></image>
  26. <button type="primary">去购买</button>
  27. </view>
  28. </view>
  29. <view class="self-setting-box" @click.stop="goRechargePage()">
  30. <view class="setting-content-box" style="border-bottom: 1upx solid #d9d9d9">
  31. <view class="setting-content-text">
  32. <image src="../../static/icon/moneyIcon.png" mode=""></image>
  33. <text>充值记录</text>
  34. </view>
  35. <view style="margin-right: 2%;margin-top: 2%;">
  36. <image src="../../static/icon/arrowIcon.png" mode="" style="width: 32upx;height:32upx;"></image>
  37. </view>
  38. </view>
  39. <view class="setting-content-box" @click.stop="goMyAskPage()">
  40. <view class="setting-content-text">
  41. <image src="../../static/icon/askIcon.png" mode="" class="askIcon"></image>
  42. <text>我的咨询</text>
  43. </view>
  44. <view style="margin-right: 2%;margin-top: 2%;">
  45. <image src="../../static/icon/arrowIcon.png" mode="" style="width: 32upx;height:32upx;"></image>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. var md5 = require("../../common/md5.js");
  53. export default {
  54. data() {
  55. return {
  56. title: '个人中心页面',
  57. nowHeight:getApp().globalData.glbalHeight,
  58. isShowAuthBtn:getApp().globalData.isAuth,
  59. userName:getApp().globalData.user_name || '阿拉灯神丁',
  60. userHeadUrl:getApp().globalData.user_headUrl || '../../static/rabotHead.png',
  61. userTime:getApp().globalData.times,
  62. userTotalTime:getApp().globalData.total_times
  63. }
  64. },
  65. onLoad() {
  66. },
  67. onShow(){
  68. this.loginUserInfo();
  69. },
  70. methods: {
  71. // 获取用户信息
  72. getUserInfo(e) {
  73. if (e.detail.errMsg == "getUserInfo:ok") {
  74. this.userHeadUrl = e.detail.userInfo.avatarUrl;
  75. this.userName = e.detail.userInfo.nickName;
  76. getApp().globalData.user_name =e.detail.userInfo.nickName;
  77. getApp().globalData.user_headUrl = e.detail.userInfo.avatarUrl;
  78. this.isShowAuthBtn = false;
  79. this.loginUserInfo()
  80. } else {
  81. console.log("用户信息授权失败");
  82. this.isShowAuthBtn = true;
  83. }
  84. },
  85. loginUserInfo(){
  86. let that = this;
  87. uni.request({
  88. url:getApp().globalData.shareUrl, //需要设置为全局
  89. method: 'POST',
  90. header: {
  91. 'content-type': 'application/x-www-form-urlencoded'
  92. },
  93. data: {
  94. method: 'auth',
  95. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  96. uid:getApp().globalData.user_id,
  97. sign: md5('auth' + getApp().globalData.globalTimestamp),
  98. nickname:getApp().globalData.user_name,
  99. headimg:getApp().globalData.user_headUrl
  100. },
  101. success: res => {
  102. that.userTime = res.data.msg.times;
  103. that.userTotalTime = res.data.msg.total_times;
  104. getApp().globalData.times = res.data.msg.times;
  105. getApp().globalData.total_times = res.data.msg.total_times;
  106. }
  107. });
  108. },
  109. goMyAskPage(){
  110. uni.navigateBack({
  111. delta:0
  112. })
  113. },
  114. goRechargePage(){
  115. uni.navigateTo({
  116. url: './rechargeRecord/rechargeRecord',
  117. success: res => {},
  118. fail: () => {},
  119. complete: () => {}
  120. });
  121. },
  122. goPayPage(){
  123. uni.navigateTo({
  124. url: './payList/payList',
  125. success: res => {},
  126. fail: () => {},
  127. complete: () => {}
  128. });
  129. }
  130. }
  131. }
  132. </script>
  133. <style>
  134. .content {
  135. display: flex;
  136. flex-direction: column;
  137. align-items: center;
  138. justify-content: flex-start;
  139. background: #f4f5f7;
  140. }
  141. .self-title-box {
  142. height: 120upx;
  143. width: 100%;
  144. background: #27BCEF;
  145. display: flex;
  146. justify-content: flex-start;
  147. align-items: center;
  148. color: #fff;
  149. position: relative;
  150. }
  151. .login-button-pos{
  152. position: absolute;
  153. height: 120upx;
  154. line-height: 120upx;
  155. width: 100%;
  156. background:#27BCEF;
  157. color:#fff
  158. }
  159. .self-title-box image {
  160. width: 90rpx;
  161. height:90rpx;
  162. border-radius: 45rpx;
  163. margin-left: 7%;
  164. margin-right: 5%;
  165. }
  166. .self-search-box {
  167. height: 200upx;
  168. width: 85%;
  169. background: #fff;
  170. margin-top: 5%;
  171. display: flex;
  172. justify-content: space-around;
  173. align-items: center;
  174. }
  175. .line {
  176. height: 150rpx;
  177. width: 1rpx;
  178. background: #D9D9D9;
  179. }
  180. .search-content {
  181. height: 150upx;
  182. width: 45%;
  183. display: flex;
  184. flex-direction: column;
  185. justify-content: space-around;
  186. align-items: center;
  187. }
  188. .search-content-value {
  189. color: #27BCEF;
  190. font-weight: bold;
  191. font-size: 42rpx;
  192. }
  193. .search-content-text {
  194. color: #888;
  195. font-size: 26rpx;
  196. }
  197. .self-pay-box {
  198. height: 200upx;
  199. width: 85%;
  200. background: #fff;
  201. margin-top: 5%;
  202. display: flex;
  203. justify-content: space-between;
  204. align-items: center;
  205. }
  206. .search-content image {
  207. width: 120rpx;
  208. height:90rpx;
  209. }
  210. .search-content button {
  211. width: 120rpx;
  212. height:60rpx;
  213. line-height: 60rpx;
  214. font-size: 26rpx;
  215. color: #fff;
  216. background-color: #27BCEF!important;
  217. padding-left: 0;
  218. padding-right: 0;
  219. }
  220. .self-setting-box {
  221. height: 200upx;
  222. width: 90%;
  223. background: #fff;
  224. margin-top: 5%;
  225. }
  226. .setting-content-box {
  227. display: flex;
  228. justify-content: space-between;
  229. align-items: center;
  230. height: 100upx;
  231. }
  232. .setting-content-text {
  233. display: flex;
  234. align-items: center;
  235. width: 50%;
  236. }
  237. .setting-content-text image {
  238. width: 60upx;
  239. height:60upx;
  240. margin-left: 5%;
  241. margin-right: 3%;
  242. }
  243. .askIcon{
  244. width: 45rpx!important;
  245. height: 45rpx!important;
  246. margin-left: 8%!important;
  247. margin-right: 5%!important;
  248. }
  249. .setting-content-text text {
  250. font-size:30rpx;
  251. }
  252. </style>