my.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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="kf">
  92. <button class="left-btn" open-type='contact'>联系客服</button>
  93. </view>
  94. <u-cell :border='false' title="去商家端" isLink url="/pageA/enter/enter"></u-cell>
  95. </u-cell-group>
  96. </view>
  97. </view>
  98. <view v-if='userInfo.nickname' class='quit-login' @click='quitLogin'>退出账号</view>
  99. <!-- <view class="exit" @click="exit" v-if="userInfo.phone">
  100. 退出账号
  101. </view> -->
  102. <login-pop-up ref='loginpopup' :content='"手机登录后才能查看我的哦~"'></login-pop-up>
  103. </view>
  104. </template>
  105. <script>
  106. var that;
  107. import uploadImage from '@/components/ossutil/uploadFile.js';
  108. import loginPopUp from "@/components/loginPopUp/index.vue"
  109. export default {
  110. components: {
  111. loginPopUp
  112. },
  113. data() {
  114. return {
  115. edit: false,
  116. offset: ['-2', '-27%'],
  117. type: "warning",
  118. value: '88',
  119. title: 'Hello',
  120. userInfo: {},
  121. }
  122. },
  123. onLoad() {
  124. that = this
  125. },
  126. onShow() {
  127. this.userInfo = uni.getStorageSync("userInfo")
  128. if (!this.userInfo.phone) {
  129. this.$refs.loginpopup.open()
  130. } else {
  131. var reg = /1(\d{2})\d{4}(\d{4})/g;
  132. this.userInfo.phone1 = this.userInfo.phone.replace(reg, "1$1****$2");
  133. console.log(this.userInfo)
  134. }
  135. },
  136. methods: {
  137. todetail(){
  138. uni.navigateTo({
  139. url:"/pageA/notice/index"
  140. })
  141. },
  142. quitLogin(){
  143. uni.showModal({
  144. title: '提示',
  145. content: '确定退出当前账号?',
  146. success (res) {
  147. if (res.confirm) {
  148. uni.removeStorageSync("userInfo")
  149. that.userInfo = {}
  150. setTimeout(()=>{
  151. that.reload()
  152. },500)
  153. } else if (res.cancel) {
  154. console.log('用户点击取消')
  155. }
  156. }
  157. })
  158. },
  159. reload() {
  160. // 页面重载
  161. const pages = getCurrentPages()
  162. // 声明一个pages使用getCurrentPages方法
  163. const curPage = pages[pages.length - 1]
  164. // 声明一个当前页面
  165. curPage.onLoad(curPage.options) // 传入参数
  166. curPage.onShow()
  167. curPage.onReady()
  168. // 执行刷新
  169. },
  170. editNickName() {
  171. this.$request.baseRequest('admin.unimall.commonUserInfo', 'update', {
  172. commonUserInfo: JSON.stringify(this.userInfo)
  173. }, failres => {
  174. uni.showToast({
  175. icon: "none",
  176. title: failres.errmsg,
  177. duration: 3000
  178. });
  179. }).then(res => {
  180. uni.setStorageSync("userInfo", this.userInfo)
  181. this.edit = false
  182. })
  183. },
  184. login() {
  185. if (!uni.getStorageSync("userInfo").phone) {
  186. this.$refs.loginpopup.open()
  187. } else {
  188. uni.navigateTo({
  189. url: '/pages/my/editNickName'
  190. })
  191. }
  192. },
  193. exit() {
  194. uni.setStorageSync("userInfo", {})
  195. this.userInfo = {}
  196. this.$forceUpdate()
  197. },
  198. editHead() {
  199. if (this.userInfo.phone) {
  200. uni.chooseImage({
  201. count: 1,
  202. sizeType: ['original', 'compressed'],
  203. success: function(res) {
  204. uploadImage(res.tempFilePaths[0], 'cardImages/',
  205. result => {
  206. that.userInfo.head = result
  207. that.$request.baseRequest('admin.unimall.commonUserInfo', 'update', {
  208. commonUserInfo: JSON.stringify(that.userInfo)
  209. }, failres => {
  210. uni.hideLoading()
  211. uni.showToast({
  212. icon: "none",
  213. title: failres.errmsg,
  214. duration: 3000
  215. });
  216. }).then(res => {
  217. uni.setStorageSync("userInfo", that.userInfo)
  218. uni.showToast({
  219. icon: "success",
  220. title: '修改成功!',
  221. duration: 2000,
  222. complete: function() {
  223. uni.switchTab({
  224. url: "/pages/my/my"
  225. })
  226. }
  227. })
  228. })
  229. }
  230. )
  231. }
  232. });
  233. } else {
  234. this.showAuthorizePhone = true
  235. }
  236. },
  237. }
  238. }
  239. </script>
  240. <style lang='scss' scoped>
  241. .content {
  242. display: flex;
  243. flex-direction: column;
  244. align-items: center;
  245. justify-content: center;
  246. }
  247. .logo {
  248. height: 200rpx;
  249. width: 200rpx;
  250. margin-top: 200rpx;
  251. margin-left: auto;
  252. margin-right: auto;
  253. margin-bottom: 50rpx;
  254. }
  255. .text-area {
  256. display: flex;
  257. justify-content: center;
  258. }
  259. .title {
  260. font-size: 36rpx;
  261. color: #8f8f94;
  262. }
  263. .wrap{
  264. width:92vw;
  265. padding:0 20rpx;
  266. }
  267. .orderList {
  268. display: flex;
  269. flex-wrap: wrap;
  270. .orderItem {
  271. width: 48%;
  272. padding: 20rpx;
  273. background: #E5EBFF;
  274. box-sizing: border-box;
  275. margin: 5rpx;
  276. border-radius: 10rpx;
  277. display: flex;
  278. }
  279. /deep/.u-badge {
  280. z-index: 50;
  281. }
  282. .orderName {
  283. margin-left: 20rpx;
  284. }
  285. }
  286. .user {
  287. background: #fff;
  288. width: 100%;
  289. padding: 10rpx 20rpx;
  290. }
  291. .userWrap {
  292. width: 92vw;
  293. margin: 0 auto;
  294. }
  295. .kf {
  296. border-bottom-width: 1px;
  297. border-bottom-style: solid;
  298. width: 100%;
  299. border-color: #d6d7d9;
  300. padding: 20rpx;
  301. box-sizing: border-box;
  302. }
  303. .left-btn {
  304. padding: 0;
  305. margin: 0;
  306. font-size: 30rpx;
  307. height: 42rpx;
  308. display: flex;
  309. align-items: center;
  310. background-color: #fff;
  311. margin-left: 10rpx;
  312. }
  313. .left-btn:after {
  314. border: none !important;
  315. }
  316. .exit {
  317. width: 100vw;
  318. background-color: #fff;
  319. font-size: 30rpx;
  320. margin-top: 20rpx;
  321. text-align: center;
  322. padding: 20rpx;
  323. }
  324. .quit-login{
  325. background:#fff;
  326. width:91%;
  327. padding:10rpx 20rpx;
  328. text-align:center;
  329. margin:10rpx 20rpx;
  330. border-radius:10rpx;
  331. }
  332. </style>