my.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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. <image style='width:22px;height:22px;' src="../../static/image/yjt.png" mode=""></image>
  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. tabbarChange(e){
  139. console.log(e)
  140. if(e=='team'){
  141. uni.navigateTo({
  142. url:'/pageA/notice/index'
  143. })
  144. }else if(e=='user'){
  145. uni.navigateTo({
  146. url:'/pageA/my/my'
  147. })
  148. }
  149. // name => tabbarCheck = name
  150. },
  151. todetail(){
  152. uni.navigateTo({
  153. url:"/pageA/notice/index"
  154. })
  155. },
  156. quitLogin(){
  157. uni.showModal({
  158. title: '提示',
  159. content: '确定退出当前账号?',
  160. success (res) {
  161. if (res.confirm) {
  162. uni.removeStorageSync("userInfo")
  163. that.userInfo = {}
  164. setTimeout(()=>{
  165. that.reload()
  166. },500)
  167. } else if (res.cancel) {
  168. console.log('用户点击取消')
  169. }
  170. }
  171. })
  172. },
  173. reload() {
  174. // 页面重载
  175. const pages = getCurrentPages()
  176. // 声明一个pages使用getCurrentPages方法
  177. const curPage = pages[pages.length - 1]
  178. // 声明一个当前页面
  179. curPage.onLoad(curPage.options) // 传入参数
  180. curPage.onShow()
  181. curPage.onReady()
  182. // 执行刷新
  183. },
  184. editNickName() {
  185. this.$request.baseRequest('admin.unimall.commonUserInfo', 'update', {
  186. commonUserInfo: JSON.stringify(this.userInfo)
  187. }, failres => {
  188. uni.showToast({
  189. icon: "none",
  190. title: failres.errmsg,
  191. duration: 3000
  192. });
  193. }).then(res => {
  194. uni.setStorageSync("userInfo", this.userInfo)
  195. this.edit = false
  196. })
  197. },
  198. login() {
  199. if (!uni.getStorageSync("userInfo").phone) {
  200. this.$refs.loginpopup.open()
  201. } else {
  202. uni.navigateTo({
  203. url: '/pages/my/editNickName'
  204. })
  205. }
  206. },
  207. exit() {
  208. uni.setStorageSync("userInfo", {})
  209. this.userInfo = {}
  210. this.$forceUpdate()
  211. },
  212. editHead() {
  213. if (this.userInfo.phone) {
  214. uni.chooseImage({
  215. count: 1,
  216. sizeType: ['original', 'compressed'],
  217. success: function(res) {
  218. uploadImage(res.tempFilePaths[0], 'cardImages/',
  219. result => {
  220. that.userInfo.head = result
  221. that.$request.baseRequest('admin.unimall.commonUserInfo', 'update', {
  222. commonUserInfo: JSON.stringify(that.userInfo)
  223. }, failres => {
  224. uni.hideLoading()
  225. uni.showToast({
  226. icon: "none",
  227. title: failres.errmsg,
  228. duration: 3000
  229. });
  230. }).then(res => {
  231. uni.setStorageSync("userInfo", that.userInfo)
  232. uni.showToast({
  233. icon: "success",
  234. title: '修改成功!',
  235. duration: 2000,
  236. complete: function() {
  237. uni.switchTab({
  238. url: "/pages/my/my"
  239. })
  240. }
  241. })
  242. })
  243. }
  244. )
  245. }
  246. });
  247. } else {
  248. this.showAuthorizePhone = true
  249. }
  250. },
  251. }
  252. }
  253. </script>
  254. <style lang='scss' scoped>
  255. .content {
  256. display: flex;
  257. flex-direction: column;
  258. align-items: center;
  259. justify-content: center;
  260. }
  261. .logo {
  262. height: 200rpx;
  263. width: 200rpx;
  264. margin-top: 200rpx;
  265. margin-left: auto;
  266. margin-right: auto;
  267. margin-bottom: 50rpx;
  268. }
  269. .text-area {
  270. display: flex;
  271. justify-content: center;
  272. }
  273. .title {
  274. font-size: 36rpx;
  275. color: #8f8f94;
  276. }
  277. .wrap{
  278. width:92vw;
  279. padding:0 20rpx;
  280. }
  281. .orderList {
  282. display: flex;
  283. flex-wrap: wrap;
  284. .orderItem {
  285. width: 48%;
  286. padding: 20rpx;
  287. background: #E5EBFF;
  288. box-sizing: border-box;
  289. margin: 5rpx;
  290. border-radius: 10rpx;
  291. display: flex;
  292. }
  293. /deep/.u-badge {
  294. z-index: 50;
  295. }
  296. .orderName {
  297. margin-left: 20rpx;
  298. }
  299. }
  300. .user {
  301. background: #fff;
  302. width: 100%;
  303. padding: 10rpx 20rpx;
  304. }
  305. .userWrap {
  306. width: 92vw;
  307. margin: 0 auto;
  308. }
  309. .kf {
  310. border-bottom-width: 1px;
  311. border-bottom-style: solid;
  312. width: 100%;
  313. border-color: #d6d7d9;
  314. padding: 20rpx;
  315. box-sizing: border-box;
  316. }
  317. .left-btn {
  318. padding: 0;
  319. margin: 0;
  320. font-size: 30rpx;
  321. height: 42rpx;
  322. display: flex;
  323. align-items: center;
  324. background-color: #fff;
  325. margin-left: 10rpx;
  326. }
  327. .left-btn:after {
  328. border: none !important;
  329. }
  330. .exit {
  331. width: 100vw;
  332. background-color: #fff;
  333. font-size: 30rpx;
  334. margin-top: 20rpx;
  335. text-align: center;
  336. padding: 20rpx;
  337. }
  338. .quit-login{
  339. background:#fff;
  340. width:91%;
  341. padding:10rpx 20rpx;
  342. text-align:center;
  343. margin:10rpx 20rpx;
  344. border-radius:10rpx;
  345. }
  346. </style>