selfInfo.vue 7.4 KB

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