index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <view class="user-content">
  3. <!-- 头部 -->
  4. <view class="user-head" >
  5. <view>
  6. <open-data type="userAvatarUrl" class="user-photo"></open-data>
  7. <!-- <u-image v-show="!hasLogin" src="/static/logo.png" width="100" height="100"></u-image> -->
  8. </view>
  9. <view class="user-info">
  10. <view v-if="hasLogin" class="user-info-item">{{userData.userName || ''}}</view>
  11. <view v-if="hasLogin" class="user-info-item">{{userData.userMobile || ''}}</view>
  12. <view v-if="!hasLogin" class="user-info-item" @click="toLoginPage">
  13. 请点击登录
  14. </view>
  15. <!-- <u-button v-else="!hasLogin" plain size="mini" shape="circle" @click="toLoginPage">立即登录</u-button> -->
  16. </view>
  17. </view>
  18. <!-- 列表 -->
  19. <view class="list-container">
  20. <navigator v-if="hasLogin" url="/pages/store/storeList" class="list-item flex align_center justify_between">
  21. <view class="flex align_center">
  22. <u-image src="/static/home/personal_store.png" width="48" height="48"></u-image>
  23. <text>店铺管理</text>
  24. </view>
  25. <u-icon name="arrow-right" color="#9DA8B5" size="32"></u-icon>
  26. </navigator>
  27. <navigator v-if="hasLogin" url="/pages/order/historyOrder" class="list-item flex align_center justify_between">
  28. <view class="flex align_center">
  29. <u-image src="/static/home/personal_historyOrder.png" width="48" height="48"></u-image>
  30. <text>历史订单</text>
  31. </view>
  32. <u-icon name="arrow-right" color="#9DA8B5" size="32"></u-icon>
  33. </navigator>
  34. <navigator v-if="hasLogin" url="/pages/recoveryTotal/index" class="list-item flex align_center justify_between">
  35. <view class="flex align_center">
  36. <u-image src="/static/home/personal_total.png" width="48" height="48"></u-image>
  37. <text>回收统计</text>
  38. </view>
  39. <u-icon name="arrow-right" color="#9DA8B5" size="32"></u-icon>
  40. </navigator>
  41. <navigator v-if="hasLogin" url="/pages/userCenter/changePwd" class="list-item flex align_center justify_between">
  42. <view class="flex align_center">
  43. <u-image src="/static/home/personal_passward.png" width="48" height="48"></u-image>
  44. <text>修改密码</text>
  45. </view>
  46. <u-icon name="arrow-right" color="#9DA8B5" size="32"></u-icon>
  47. </navigator>
  48. <view @click="checkUpdate" class="list-item flex align_center justify_between">
  49. <view class="flex align_center">
  50. <u-image src="/static/home/personal_version.png" width="48" height="48"></u-image>
  51. <text>版本检查</text>
  52. </view>
  53. <view>
  54. <text>{{version}}</text>
  55. <u-icon name="arrow-right" color="#9DA8B5" size="32"></u-icon>
  56. </view>
  57. </view>
  58. <view v-if="hasLogin" @click="quitSys" class="list-item flex align_center justify_between">
  59. <view class="flex align_center">
  60. <u-image src="/static/home/personal_loginout.png" width="48" height="48"></u-image>
  61. <text>退出登录</text>
  62. </view>
  63. <u-icon name="arrow-right" color="#9DA8B5" size="32"></u-icon>
  64. </view>
  65. </view>
  66. <!-- 客服电话 -->
  67. <view class="phone flex justify_center align_center">
  68. <u-icon name="phone" color="#191919" font-size="32" @click="callPhone"></u-icon>
  69. <text @click="callPhone">客服电话:4008826012</text>
  70. </view>
  71. </view>
  72. </template>
  73. <script>
  74. import { checkLogin, getUserInfo, logout } from '@/api/login.js'
  75. export default {
  76. data() {
  77. return {
  78. hasLogin: false,
  79. userData: {},
  80. version: '1.0.0' // 小程序版本
  81. };
  82. },
  83. onShow() {
  84. checkLogin().then(res => {
  85. this.hasLogin = res.status == 200
  86. console.log(this.hasLogin,res,'this.hasLogin')
  87. if(this.hasLogin){
  88. this.getUserInfo()
  89. }else{
  90. // uni.navigateTo({
  91. // url:"/pages/login/login"
  92. // })
  93. }
  94. })
  95. },
  96. computed: {
  97. },
  98. onLoad() {
  99. // this.getVersion()
  100. // 开启分享
  101. uni.showShareMenu({
  102. withShareTicket: true,
  103. menus: ['shareAppMessage', 'shareTimeline']
  104. })
  105. },
  106. methods:{
  107. // 获取当前小程序版本
  108. getVersion(){
  109. const accountInfo = uni.getAccountInfoSync();
  110. this.version = accountInfo.miniProgram.version
  111. console.log(accountInfo,accountInfo.miniProgram.appId,'ppppppppp'); // 小程序 appId
  112. },
  113. // 检查更新
  114. checkUpdate(){
  115. if (uni.canIUse('getUpdateManager')) {
  116. const updateManager = uni.getUpdateManager()
  117. updateManager.onCheckForUpdate(function (res) {
  118. console.log('onCheckForUpdate====', res)
  119. // 请求完新版本信息的回调
  120. if (res.hasUpdate) {
  121. console.log('res.hasUpdate====')
  122. updateManager.onUpdateReady(function () {
  123. uni.showModal({
  124. title: '更新提示',
  125. content: '新版本已经准备好,是否重启应用?',
  126. success: function (res) {
  127. console.log('success====', res)
  128. // res: {errMsg: "showModal: ok", cancel: false, confirm: true}
  129. if (res.confirm) {
  130. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  131. updateManager.applyUpdate()
  132. }
  133. }
  134. })
  135. })
  136. updateManager.onUpdateFailed(function () {
  137. // 新的版本下载失败
  138. uni.showModal({
  139. title: '已经有新版本了哟~',
  140. content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~'
  141. })
  142. })
  143. } else {
  144. uni.showToast({
  145. title: '已是最新版本',
  146. icon: 'none'
  147. })
  148. }
  149. })
  150. }
  151. },
  152. // 获取用户信息
  153. getUserInfo(){
  154. getUserInfo().then(res => {
  155. console.log(res,'getUserInfo')
  156. if(res.status == 200){
  157. this.$u.vuex("vuex_userData",res.data)
  158. this.userData = res.data
  159. console.log(this.userData,'-----用户信息')
  160. }
  161. })
  162. },
  163. // 打开对应的页面
  164. toPage(index){
  165. console.log(index)
  166. let pageUrl=[
  167. '/pages/agreement/agreement?fromPage=usercenter',
  168. '/pages/userCenter/changePwd',
  169. ]
  170. uni.navigateTo({
  171. url: pageUrl[index]
  172. })
  173. },
  174. // 退出登录
  175. quitSys(){
  176. let _this = this
  177. uni.showModal({
  178. title: '提示',
  179. content: '您确定要退出登录吗?',
  180. success(res) {
  181. if (res.confirm) {
  182. logout().then(res => {
  183. console.log(res,'logout')
  184. getApp().globalData.token = ''
  185. _this.$u.vuex('vuex_token','')
  186. // 关闭socket
  187. uni.reLaunch({
  188. url: '/pages/login/login'
  189. })
  190. })
  191. }
  192. }
  193. })
  194. },
  195. toLoginPage(){
  196. uni.navigateTo({
  197. url: '/pages/login/login'
  198. })
  199. },
  200. //联系客服
  201. callPhone(){
  202. uni.makePhoneCall({
  203. phoneNumber: "4008826012"
  204. });
  205. }
  206. }
  207. }
  208. </script>
  209. <style lang="scss">
  210. .user-content{
  211. width: 100%;
  212. height: 100vh;
  213. background-color: #fff;
  214. .user-head{
  215. display: flex;
  216. align-items: center;
  217. padding: 35rpx 55rpx;
  218. .user-info{
  219. flex-grow: 1;
  220. padding: 0 20rpx;
  221. color: #FFFFFF;
  222. .user-info-item{
  223. margin: 10rpx 0;
  224. color: #666666;
  225. font-size: 32upx;
  226. }
  227. :first-child{
  228. color: #000000;
  229. font-size: 48upx;
  230. }
  231. }
  232. .user-photo{
  233. display: block;
  234. width: 146rpx;
  235. height: 146rpx;
  236. border-radius: 50%;
  237. overflow: hidden;
  238. }
  239. }
  240. .list-container{
  241. width: 100%;
  242. .icon{
  243. width: 48rpx;
  244. height: 48rpx;
  245. margin-right: 30rpx;
  246. }
  247. .list-item{
  248. padding: 32rpx 36rpx;
  249. background-color: #fff;
  250. text{
  251. display: inline-block;
  252. margin-left: 28upx;
  253. font-size: 34rpx;
  254. color: #191919;
  255. }
  256. }
  257. .margin-bot{
  258. margin-bottom: 20rpx;
  259. }
  260. }
  261. .phone{
  262. text-align: center;
  263. margin-top: 20%;
  264. }
  265. }
  266. </style>