my.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. <template>
  2. <view class="content">
  3. <view class='user'>
  4. <view class='flex userWrap justify-space-between'>
  5. <view class='flex'>
  6. <view style='margin-right:20rpx;'>
  7. <u--image width='60' height='60' :src="userInfo.head" shape="circle"
  8. @click="editHead"></u--image>
  9. </view>
  10. <view>
  11. <view class='flex'>
  12. <view @click='login' style="font-weight: bold;font-size: 32rpx;">
  13. {{userInfo.nickname?userInfo.nickname:'请点击登录'}}
  14. </view>
  15. <!-- <view v-else>
  16. <u--input placeholder="请输入内容" border="bottom" v-model='userInfo.nickname'
  17. clearable></u--input>
  18. </view> -->
  19. <!-- <u-icon v-if='!edit&&userInfo.phone' @click='edit = true' name="edit-pen-fill"
  20. color="#eaad1a" size="24"></u-icon>
  21. <u-icon v-if='edit&&userInfo.phone' @click='editNickName' name="checkbox-mark"
  22. color="#eaad1a" size="24"></u-icon> -->
  23. </view>
  24. <view>{{userInfo.phone1}}</view>
  25. </view>
  26. </view>
  27. <view>
  28. <u-icon @click='todetail' name="bell" color="#eaad1a" size="28"></u-icon>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="wrap">
  33. <!-- <view class='orderList'>
  34. <view class="orderItem align-item-center">
  35. <view style='position:relative;'>
  36. <u-icon name="home-fill" color="#2979ff" size="28"></u-icon>
  37. <u-badge :offset='offset' absolute='true' bgColor='red' max="99" :value="value"></u-badge>
  38. </view>
  39. <view class='orderName'>入住订单</view>
  40. </view>
  41. <view class="orderItem align-item-center">
  42. <view style='position:relative;'>
  43. <u-icon name="home-fill" color="#2979ff" size="28"></u-icon>
  44. <u-badge :offset='offset' absolute='true' bgColor='red' max="99" :value="value"></u-badge>
  45. </view>
  46. <view class='orderName'>特产订单</view>
  47. </view>
  48. <view class="orderItem align-item-center">
  49. <view style='position:relative;'>
  50. <u-icon name="home-fill" color="#2979ff" size="28"></u-icon>
  51. <u-badge :offset='offset' absolute='true' bgColor='red' max="99" :value="value"></u-badge>
  52. </view>
  53. <view class='orderName'>团购订单</view>
  54. </view>
  55. <view class="orderItem align-item-center">
  56. <view style='position:relative;'>
  57. <u-icon name="home-fill" color="#2979ff" size="28"></u-icon>
  58. <u-badge :offset='offset' absolute='true' bgColor='red' max="99" :value="value"></u-badge>
  59. </view>
  60. <view class='orderName'>门票订单</view>
  61. </view>
  62. </view> -->
  63. <view style='width:100%;'>
  64. <u-cell-group :border='false'>
  65. <!-- <u-cell
  66. title="收货地址"
  67. isLink
  68. url="/pages/componentsB/tag/tag"
  69. ></u-cell> -->
  70. <u-cell title="我的发布" isLink url="/pageA/my/mypublish"></u-cell>
  71. <!-- <u-cell
  72. title="房源发布"
  73. isLink
  74. url="/pages/componentsB/badge/badge"
  75. ></u-cell> -->
  76. <!-- <u-cell
  77. title="商家入驻"
  78. isLink
  79. url="/pages/componentsB/badge/badge"
  80. ></u-cell> -->
  81. <!-- <u-cell
  82. title="业务合作"
  83. isLink
  84. url="/pages/componentsB/badge/badge"
  85. ></u-cell> -->
  86. <!-- <u-cell
  87. title="广告推广"
  88. isLink
  89. url="/pages/componentsB/badge/badge"
  90. ></u-cell> -->
  91. <view class="flex justify-space-between kf">
  92. <button class="left-btn" open-type='contact'>联系客服</button>
  93. <u-icon name="arrow-right" color="#909399" size="16"></u-icon>
  94. </view>
  95. <u-cell :border='false' title="去商家端" isLink url="/pageA/enter/enter"></u-cell>
  96. </u-cell-group>
  97. </view>
  98. </view>
  99. <view v-if='userInfo.nickname' class='quit-login' @click='quitLogin'>退出账号</view>
  100. <!-- <view class="exit" @click="exit" v-if="userInfo.phone">
  101. 退出账号
  102. </view> -->
  103. <login-pop-up ref='loginpopup' :content='"手机登录后才能查看我的哦~"'></login-pop-up>
  104. </view>
  105. </template>
  106. <script>
  107. var that;
  108. import uploadImage from '@/components/ossutil/uploadFile.js';
  109. import loginPopUp from "@/components/loginPopUp/index.vue"
  110. export default {
  111. components: {
  112. loginPopUp
  113. },
  114. data() {
  115. return {
  116. edit: false,
  117. offset: ['-2', '-27%'],
  118. type: "warning",
  119. value: '88',
  120. title: 'Hello',
  121. userInfo: {},
  122. }
  123. },
  124. onLoad() {
  125. that = this
  126. },
  127. onShow() {
  128. this.userInfo = uni.getStorageSync("userInfo")
  129. if (!this.userInfo.phone) {
  130. this.$refs.loginpopup.open()
  131. } else {
  132. var reg = /1(\d{2})\d{4}(\d{4})/g;
  133. this.userInfo.phone1 = this.userInfo.phone.replace(reg, "1$1****$2");
  134. console.log(this.userInfo)
  135. }
  136. },
  137. methods: {
  138. todetail(){
  139. uni.navigateTo({
  140. url:"/pageA/notice/index"
  141. })
  142. },
  143. quitLogin(){
  144. uni.showModal({
  145. title: '提示',
  146. content: '确定退出当前账号?',
  147. success (res) {
  148. if (res.confirm) {
  149. uni.removeStorageSync("userInfo")
  150. that.userInfo = {}
  151. setTimeout(()=>{
  152. that.reload()
  153. },500)
  154. } else if (res.cancel) {
  155. console.log('用户点击取消')
  156. }
  157. }
  158. })
  159. },
  160. reload() {
  161. // 页面重载
  162. const pages = getCurrentPages()
  163. // 声明一个pages使用getCurrentPages方法
  164. const curPage = pages[pages.length - 1]
  165. // 声明一个当前页面
  166. curPage.onLoad(curPage.options) // 传入参数
  167. curPage.onShow()
  168. curPage.onReady()
  169. // 执行刷新
  170. },
  171. editNickName() {
  172. this.$request.baseRequest('admin.unimall.commonUserInfo', 'update', {
  173. commonUserInfo: JSON.stringify(this.userInfo)
  174. }, failres => {
  175. uni.showToast({
  176. icon: "none",
  177. title: failres.errmsg,
  178. duration: 3000
  179. });
  180. }).then(res => {
  181. uni.setStorageSync("userInfo", this.userInfo)
  182. this.edit = false
  183. })
  184. },
  185. login() {
  186. if (!uni.getStorageSync("userInfo").phone) {
  187. this.$refs.loginpopup.open()
  188. } else {
  189. uni.navigateTo({
  190. url: '/pages/my/editNickName'
  191. })
  192. }
  193. },
  194. exit() {
  195. uni.setStorageSync("userInfo", {})
  196. this.userInfo = {}
  197. this.$forceUpdate()
  198. },
  199. editHead() {
  200. if (this.userInfo.phone) {
  201. uni.chooseImage({
  202. count: 1,
  203. sizeType: ['original', 'compressed'],
  204. success: function(res) {
  205. uploadImage(res.tempFilePaths[0], 'cardImages/',
  206. result => {
  207. that.userInfo.head = result
  208. that.$request.baseRequest('admin.unimall.commonUserInfo', 'update', {
  209. commonUserInfo: JSON.stringify(that.userInfo)
  210. }, failres => {
  211. uni.hideLoading()
  212. uni.showToast({
  213. icon: "none",
  214. title: failres.errmsg,
  215. duration: 3000
  216. });
  217. }).then(res => {
  218. uni.setStorageSync("userInfo", that.userInfo)
  219. uni.showToast({
  220. icon: "success",
  221. title: '修改成功!',
  222. duration: 2000,
  223. complete: function() {
  224. uni.switchTab({
  225. url: "/pages/my/my"
  226. })
  227. }
  228. })
  229. })
  230. }
  231. )
  232. }
  233. });
  234. } else {
  235. this.showAuthorizePhone = true
  236. }
  237. },
  238. }
  239. }
  240. </script>
  241. <style lang='scss' scoped>
  242. .content {
  243. display: flex;
  244. flex-direction: column;
  245. align-items: center;
  246. justify-content: center;
  247. }
  248. .logo {
  249. height: 200rpx;
  250. width: 200rpx;
  251. margin-top: 200rpx;
  252. margin-left: auto;
  253. margin-right: auto;
  254. margin-bottom: 50rpx;
  255. }
  256. .text-area {
  257. display: flex;
  258. justify-content: center;
  259. }
  260. .title {
  261. font-size: 36rpx;
  262. color: #8f8f94;
  263. }
  264. .wrap{
  265. width:92vw;
  266. padding:0 20rpx;
  267. }
  268. .orderList {
  269. display: flex;
  270. flex-wrap: wrap;
  271. .orderItem {
  272. width: 48%;
  273. padding: 20rpx;
  274. background: #E5EBFF;
  275. box-sizing: border-box;
  276. margin: 5rpx;
  277. border-radius: 10rpx;
  278. display: flex;
  279. }
  280. /deep/.u-badge {
  281. z-index: 50;
  282. }
  283. .orderName {
  284. margin-left: 20rpx;
  285. }
  286. }
  287. .user {
  288. background: #fff;
  289. width: 100%;
  290. padding: 10rpx 20rpx;
  291. }
  292. .userWrap {
  293. width: 92vw;
  294. margin: 0 auto;
  295. }
  296. .kf {
  297. border-bottom-width: 1px;
  298. border-bottom-style: solid;
  299. width: 100%;
  300. border-color: #d6d7d9;
  301. padding: 20rpx 22rpx;
  302. box-sizing: border-box;
  303. }
  304. .left-btn {
  305. padding: 0;
  306. margin: 0;
  307. font-size: 15px;
  308. height: 42rpx;
  309. display: flex;
  310. align-items: center;
  311. background-color: #fff;
  312. margin-left: 10rpx;
  313. }
  314. .left-btn:after {
  315. border: none !important;
  316. }
  317. .exit {
  318. width: 100vw;
  319. background-color: #fff;
  320. font-size: 30rpx;
  321. margin-top: 20rpx;
  322. text-align: center;
  323. padding: 20rpx;
  324. }
  325. .quit-login{
  326. background:#fff;
  327. width:91%;
  328. padding:10rpx 20rpx;
  329. text-align:center;
  330. margin:10rpx 20rpx;
  331. border-radius:10rpx;
  332. }
  333. </style>