selfInfo.vue 7.4 KB

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