selfInfo.vue 9.5 KB

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