selfInfo.vue 8.2 KB

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