selfInfo.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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.isShowAuthBtn = res.data.msg.isauth === '0';
  103. that.userTime = res.data.msg.times;
  104. that.userTotalTime = res.data.msg.total_times;
  105. getApp().globalData.times = res.data.msg.times;
  106. getApp().globalData.total_times = res.data.msg.total_times;
  107. }
  108. });
  109. },
  110. goMyAskPage(){
  111. uni.navigateBack({
  112. delta:0
  113. })
  114. },
  115. goRechargePage(){
  116. uni.navigateTo({
  117. url: './rechargeRecord/rechargeRecord',
  118. success: res => {},
  119. fail: () => {},
  120. complete: () => {}
  121. });
  122. },
  123. goPayPage(){
  124. uni.navigateTo({
  125. url: './payList/payList',
  126. success: res => {},
  127. fail: () => {},
  128. complete: () => {}
  129. });
  130. }
  131. }
  132. }
  133. </script>
  134. <style>
  135. .content {
  136. display: flex;
  137. flex-direction: column;
  138. align-items: center;
  139. justify-content: flex-start;
  140. background: #f4f5f7;
  141. }
  142. .self-title-box {
  143. height: 120upx;
  144. width: 100%;
  145. background: #27BCEF;
  146. display: flex;
  147. justify-content: flex-start;
  148. align-items: center;
  149. color: #fff;
  150. position: relative;
  151. }
  152. .login-button-pos{
  153. position: absolute;
  154. height: 120upx;
  155. line-height: 120upx;
  156. width: 100%;
  157. background:#27BCEF;
  158. color:#fff
  159. }
  160. .self-title-box image {
  161. width: 90rpx;
  162. height:90rpx;
  163. border-radius: 45rpx;
  164. margin-left: 7%;
  165. margin-right: 5%;
  166. }
  167. .self-search-box {
  168. height: 200upx;
  169. width: 85%;
  170. background: #fff;
  171. margin-top: 5%;
  172. display: flex;
  173. justify-content: space-around;
  174. align-items: center;
  175. }
  176. .line {
  177. height: 150rpx;
  178. width: 1rpx;
  179. background: #D9D9D9;
  180. }
  181. .search-content {
  182. height: 150upx;
  183. width: 45%;
  184. display: flex;
  185. flex-direction: column;
  186. justify-content: space-around;
  187. align-items: center;
  188. }
  189. .search-content-value {
  190. color: #27BCEF;
  191. font-weight: bold;
  192. font-size: 42rpx;
  193. }
  194. .search-content-text {
  195. color: #888;
  196. font-size: 26rpx;
  197. }
  198. .self-pay-box {
  199. height: 200upx;
  200. width: 85%;
  201. background: #fff;
  202. margin-top: 5%;
  203. display: flex;
  204. justify-content: space-between;
  205. align-items: center;
  206. }
  207. .search-content image {
  208. width: 120rpx;
  209. height:90rpx;
  210. }
  211. .search-content button {
  212. width: 120rpx;
  213. height:60rpx;
  214. line-height: 60rpx;
  215. font-size: 26rpx;
  216. color: #fff;
  217. background-color: #27BCEF!important;
  218. padding-left: 0;
  219. padding-right: 0;
  220. }
  221. .self-setting-box {
  222. height: 200upx;
  223. width: 90%;
  224. background: #fff;
  225. margin-top: 5%;
  226. }
  227. .setting-content-box {
  228. display: flex;
  229. justify-content: space-between;
  230. align-items: center;
  231. height: 100upx;
  232. }
  233. .setting-content-text {
  234. display: flex;
  235. align-items: center;
  236. width: 50%;
  237. }
  238. .setting-content-text image {
  239. width: 60upx;
  240. height:60upx;
  241. margin-left: 5%;
  242. margin-right: 3%;
  243. }
  244. .askIcon{
  245. width: 45rpx!important;
  246. height: 45rpx!important;
  247. margin-left: 8%!important;
  248. margin-right: 5%!important;
  249. }
  250. .setting-content-text text {
  251. font-size:30rpx;
  252. }
  253. </style>