selfInfo.vue 7.5 KB

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