selfInfo.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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:true,
  59. userName:getApp().globalData.user_name,
  60. userHeadUrl:getApp().globalData.user_headUrl,
  61. userTime:getApp().globalData.times,
  62. userTotalTime:getApp().globalData.total_times
  63. }
  64. },
  65. onLoad() {
  66. },
  67. onShow(){
  68. this.getUserTimes();
  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. getUserTimes(){
  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: 'getUserInfo',
  95. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  96. uid:getApp().globalData.user_id,
  97. sign: md5('getUserInfo' + getApp().globalData.globalTimestamp),
  98. },
  99. success: res => {
  100. that.isShowAuthBtn = res.data.msg.isauth === '0';
  101. that.userTime = res.data.msg.times;
  102. that.userTotalTime = res.data.msg.total_times;
  103. getApp().globalData.times = res.data.msg.times;
  104. getApp().globalData.total_times = res.data.msg.total_times;
  105. }
  106. });
  107. },
  108. loginUserInfo(){
  109. let that = this;
  110. uni.request({
  111. url:getApp().globalData.shareUrl, //需要设置为全局
  112. method: 'POST',
  113. header: {
  114. 'content-type': 'application/x-www-form-urlencoded'
  115. },
  116. data: {
  117. method: 'auth',
  118. timestamp: getApp().globalData.globalTimestamp, //Date.now()
  119. uid:getApp().globalData.user_id,
  120. sign: md5('auth' + getApp().globalData.globalTimestamp),
  121. nickname:getApp().globalData.user_name,
  122. headimg:getApp().globalData.user_headUrl
  123. },
  124. success: res => {
  125. console.log('已授权')
  126. }
  127. });
  128. },
  129. goMyAskPage(){
  130. uni.navigateBack({
  131. delta:0
  132. })
  133. },
  134. goRechargePage(){
  135. uni.navigateTo({
  136. url: './rechargeRecord/rechargeRecord',
  137. success: res => {},
  138. fail: () => {},
  139. complete: () => {}
  140. });
  141. },
  142. goPayPage(){
  143. uni.navigateTo({
  144. url: './payList/payList',
  145. success: res => {},
  146. fail: () => {},
  147. complete: () => {}
  148. });
  149. }
  150. }
  151. }
  152. </script>
  153. <style>
  154. .content {
  155. display: flex;
  156. flex-direction: column;
  157. align-items: center;
  158. justify-content: flex-start;
  159. background: #f4f5f7;
  160. }
  161. .self-title-box {
  162. height: 120upx;
  163. width: 100%;
  164. background: #27BCEF;
  165. display: flex;
  166. justify-content: flex-start;
  167. align-items: center;
  168. color: #fff;
  169. position: relative;
  170. }
  171. .login-button-pos{
  172. position: absolute;
  173. height: 120upx;
  174. line-height: 120upx;
  175. width: 100%;
  176. background:#27BCEF;
  177. color:#fff
  178. }
  179. .self-title-box image {
  180. width: 90rpx;
  181. height:90rpx;
  182. border-radius: 45rpx;
  183. margin-left: 7%;
  184. margin-right: 5%;
  185. }
  186. .self-search-box {
  187. height: 200upx;
  188. width: 85%;
  189. background: #fff;
  190. margin-top: 5%;
  191. display: flex;
  192. justify-content: space-around;
  193. align-items: center;
  194. }
  195. .line {
  196. height: 150rpx;
  197. width: 1rpx;
  198. background: #D9D9D9;
  199. }
  200. .search-content {
  201. height: 150upx;
  202. width: 45%;
  203. display: flex;
  204. flex-direction: column;
  205. justify-content: space-around;
  206. align-items: center;
  207. }
  208. .search-content-value {
  209. color: #27BCEF;
  210. font-weight: bold;
  211. font-size: 42rpx;
  212. }
  213. .search-content-text {
  214. color: #888;
  215. font-size: 26rpx;
  216. }
  217. .self-pay-box {
  218. height: 200upx;
  219. width: 85%;
  220. background: #fff;
  221. margin-top: 5%;
  222. display: flex;
  223. justify-content: space-between;
  224. align-items: center;
  225. }
  226. .search-content image {
  227. width: 120rpx;
  228. height:90rpx;
  229. }
  230. .search-content button {
  231. width: 120rpx;
  232. height:60rpx;
  233. line-height: 60rpx;
  234. font-size: 26rpx;
  235. color: #fff;
  236. background-color: #27BCEF!important;
  237. padding-left: 0;
  238. padding-right: 0;
  239. }
  240. .self-setting-box {
  241. height: 200upx;
  242. width: 90%;
  243. background: #fff;
  244. margin-top: 5%;
  245. }
  246. .setting-content-box {
  247. display: flex;
  248. justify-content: space-between;
  249. align-items: center;
  250. height: 100upx;
  251. }
  252. .setting-content-text {
  253. display: flex;
  254. align-items: center;
  255. width: 50%;
  256. }
  257. .setting-content-text image {
  258. width: 60upx;
  259. height:60upx;
  260. margin-left: 5%;
  261. margin-right: 3%;
  262. }
  263. .askIcon{
  264. width: 45rpx!important;
  265. height: 45rpx!important;
  266. margin-left: 8%!important;
  267. margin-right: 5%!important;
  268. }
  269. .setting-content-text text {
  270. font-size:30rpx;
  271. }
  272. </style>