index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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(customerPhoneNum)"></u-icon>
  69. <text @click="callPhone(customerPhoneNum)">客服电话:{{customerPhoneNum || '--'}}</text>
  70. </view>
  71. </view>
  72. </template>
  73. <script>
  74. import { checkLogin, getUserInfo, logout,customerPhone } from '@/api/login.js'
  75. export default {
  76. data() {
  77. return {
  78. hasLogin: false,
  79. userData: {},
  80. version: '1.0.1' ,// 小程序版本
  81. customerPhoneNum:'' // 客服电话
  82. };
  83. },
  84. onShow() {
  85. checkLogin().then(res => {
  86. this.hasLogin = res.status == 200
  87. console.log(this.hasLogin,res,'this.hasLogin')
  88. if(this.hasLogin){
  89. this.getUserInfo()
  90. }else{
  91. // uni.navigateTo({
  92. // url:"/pages/login/login"
  93. // })
  94. }
  95. })
  96. },
  97. computed: {
  98. },
  99. onLoad() {
  100. this.getCustomerPhone()
  101. // 开启分享
  102. uni.showShareMenu({
  103. withShareTicket: true,
  104. menus: ['shareAppMessage', 'shareTimeline']
  105. })
  106. },
  107. methods:{
  108. // 获取当前小程序版本
  109. getVersion(){
  110. const accountInfo = uni.getAccountInfoSync();
  111. this.version = accountInfo.miniProgram.version
  112. console.log(accountInfo,accountInfo.miniProgram.appId,'ppppppppp'); // 小程序 appId
  113. },
  114. // 获取客服电话
  115. getCustomerPhone(){
  116. customerPhone().then(res=>{
  117. console.log(res,'=====================客服电话')
  118. if(res.status==200){
  119. this.customerPhoneNum=res.data.paramPhone
  120. }else{
  121. uni.showToast({
  122. title:res.message,
  123. icon:'none'
  124. })
  125. }
  126. })
  127. },
  128. //联系客服
  129. callPhone(customerPhoneNum){
  130. uni.makePhoneCall({
  131. phoneNumber: customerPhoneNum
  132. });
  133. },
  134. // 检查更新
  135. checkUpdate(){
  136. if (uni.canIUse('getUpdateManager')) {
  137. const updateManager = uni.getUpdateManager()
  138. updateManager.onCheckForUpdate(function (res) {
  139. console.log('onCheckForUpdate====', res)
  140. // 请求完新版本信息的回调
  141. if (res.hasUpdate) {
  142. console.log('res.hasUpdate====')
  143. updateManager.onUpdateReady(function () {
  144. uni.showModal({
  145. title: '更新提示',
  146. content: '新版本已经准备好,是否重启应用?',
  147. success: function (res) {
  148. console.log('success====', res)
  149. // res: {errMsg: "showModal: ok", cancel: false, confirm: true}
  150. if (res.confirm) {
  151. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  152. updateManager.applyUpdate()
  153. }
  154. }
  155. })
  156. })
  157. updateManager.onUpdateFailed(function () {
  158. // 新的版本下载失败
  159. uni.showModal({
  160. title: '已经有新版本了哟~',
  161. content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~'
  162. })
  163. })
  164. } else {
  165. uni.showToast({
  166. title: '已是最新版本',
  167. icon: 'none'
  168. })
  169. }
  170. })
  171. }
  172. },
  173. // 获取用户信息
  174. getUserInfo(){
  175. getUserInfo().then(res => {
  176. console.log(res,'getUserInfo')
  177. if(res.status == 200){
  178. this.$u.vuex("vuex_userData",res.data)
  179. this.userData = res.data
  180. console.log(this.userData,'-----用户信息')
  181. }
  182. })
  183. },
  184. // 打开对应的页面
  185. toPage(index){
  186. console.log(index)
  187. let pageUrl=[
  188. '/pages/agreement/agreement?fromPage=usercenter',
  189. '/pages/userCenter/changePwd',
  190. ]
  191. uni.navigateTo({
  192. url: pageUrl[index]
  193. })
  194. },
  195. // 退出登录
  196. quitSys(){
  197. let _this = this
  198. uni.showModal({
  199. title: '提示',
  200. content: '您确定要退出登录吗?',
  201. success(res) {
  202. if (res.confirm) {
  203. logout().then(res => {
  204. console.log(res,'logout')
  205. getApp().globalData.token = ''
  206. _this.$u.vuex('vuex_token','')
  207. // 关闭socket
  208. uni.reLaunch({
  209. url: '/pages/login/login'
  210. })
  211. })
  212. }
  213. }
  214. })
  215. },
  216. toLoginPage(){
  217. uni.navigateTo({
  218. url: '/pages/login/login'
  219. })
  220. },
  221. }
  222. }
  223. </script>
  224. <style lang="scss">
  225. .user-content{
  226. width: 100%;
  227. height: 100vh;
  228. background-color: #fff;
  229. .user-head{
  230. display: flex;
  231. align-items: center;
  232. padding: 35rpx 55rpx;
  233. .user-info{
  234. flex-grow: 1;
  235. padding: 0 20rpx;
  236. color: #FFFFFF;
  237. .user-info-item{
  238. margin: 10rpx 0;
  239. color: #666666;
  240. font-size: 32upx;
  241. }
  242. :first-child{
  243. color: #000000;
  244. font-size: 48upx;
  245. }
  246. }
  247. .user-photo{
  248. display: block;
  249. width: 146rpx;
  250. height: 146rpx;
  251. border-radius: 50%;
  252. overflow: hidden;
  253. }
  254. }
  255. .list-container{
  256. width: 100%;
  257. .icon{
  258. width: 48rpx;
  259. height: 48rpx;
  260. margin-right: 30rpx;
  261. }
  262. .list-item{
  263. padding: 32rpx 36rpx;
  264. background-color: #fff;
  265. text{
  266. display: inline-block;
  267. margin-left: 28upx;
  268. font-size: 34rpx;
  269. color: #191919;
  270. }
  271. }
  272. .margin-bot{
  273. margin-bottom: 20rpx;
  274. }
  275. }
  276. .phone{
  277. position: absolute;
  278. text-align: center;
  279. bottom: 3%;
  280. left:28%
  281. }
  282. }
  283. </style>