index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. <!-- 我的 -->
  2. <template>
  3. <view class="my" :style="{ background: 'url(' + bgImg + ') #F4F5F9' }">
  4. <view class="title">
  5. <image :src="logoImg" mode="heightFix"></image>
  6. </view>
  7. <view class="news">
  8. <image :src="avatar"></image>
  9. <view v-if="name" class="phone">{{name}}</view>
  10. <view v-else class="phone" @click="toLogin()">点击登录</view>
  11. </view>
  12. <view class="content">
  13. <view class="order-wrap">
  14. <!-- <view class="unpay">
  15. <view class="left">
  16. <image :src="tongzhi"></image>
  17. <view class="tip">您有1笔订单待付款<text>09:34</text>后取消</view>
  18. </view>
  19. <view class="right">去付款</view>
  20. </view> -->
  21. <view class="order">
  22. <view class="order_top">
  23. <text class="mytt">我的订单</text>
  24. <view class="myall" @click="toOrder">
  25. <text class="all">全部</text>
  26. <image class="more" :src="moreImg"></image>
  27. </view>
  28. </view>
  29. <view class="order-box">
  30. <view class="order-box-item" v-for="(item, index) in orderList" :key="index" @click="toOrder(item)">
  31. <image :src="item.icon"></image>
  32. <text class="name">{{ item.label }}</text>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="cantact">
  38. <view class="canl">
  39. <image :src="cantact"></image>
  40. <text>联系客服</text>
  41. </view>
  42. <image class="more" :src="moreImg"></image>
  43. </view>
  44. <view class="outline" @click="outLogin()">退出登录</view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. import config from '@/config'
  50. import { loginWx,logout } from '@/apis/user.js'
  51. export default {
  52. components: {},
  53. data() {
  54. return {
  55. name: uni.getStorageSync('name'),
  56. token: uni.getStorageSync('token'),
  57. code: '',
  58. bgImg: "https://ovp-shop.oss-cn-hangzhou.aliyuncs.com/static/9dshop/bg_top%403x.png",
  59. logoImg: "https://ovp-shop.oss-cn-hangzhou.aliyuncs.com/static/9dshop/img_logo%403x.png",
  60. tongzhi: "https://ovp-shop.oss-cn-hangzhou.aliyuncs.com/static/9dshop/ic_tongzhi%403x.png",
  61. moreImg: "https://ovp-shop.oss-cn-hangzhou.aliyuncs.com/static/9dshop/ic_more%403x.png",
  62. cantact: "https://ovp-shop.oss-cn-hangzhou.aliyuncs.com/static/9dshop/ic_kefurexian%403x.png",
  63. avatar: '',
  64. orderList: [
  65. {
  66. value: 1,
  67. label: '全部',
  68. icon: "https://ovp-shop.oss-cn-hangzhou.aliyuncs.com/static/9dshop/ic_daifukuan%403x.png"
  69. },
  70. {
  71. value: 2,
  72. label: '待付款',
  73. icon: "https://ovp-shop.oss-cn-hangzhou.aliyuncs.com/static/9dshop/ic_daifukuan%403x.png"
  74. },
  75. {
  76. value: 3,
  77. label: '拍摄中',
  78. icon: "https://ovp-shop.oss-cn-hangzhou.aliyuncs.com/static/9dshop/ic_daifukuan%403x.png"
  79. },
  80. {
  81. value: 4,
  82. label: '已完成',
  83. icon: "https://ovp-shop.oss-cn-hangzhou.aliyuncs.com/static/9dshop/ic_diankaguanli%403x.png"
  84. }
  85. ]
  86. };
  87. },
  88. computed: {},
  89. watch: {},
  90. onLoad() {
  91. let token = uni.getStorageSync('token')
  92. if(!token){
  93. this.toLogin()
  94. }
  95. // if(code !== null || code !== "") {
  96. // this.getOpenidAndUserinfo(code)
  97. // }
  98. },
  99. onShow() {
  100. this.changeTabbar()
  101. },
  102. methods: {
  103. toLogin() {
  104. let isWX = this.isWechat()
  105. if (isWX) {
  106. // let code = this.getUrlCode('code')
  107. let code = '001t0H000xuK7U'
  108. uni.showToast({
  109. title: code,
  110. })
  111. if (code !== null && code !== undefined) {
  112. this.code = code
  113. this.getOpenidAndUserinfo(code)
  114. } else {
  115. this.getCode()
  116. }
  117. }
  118. },
  119. // 判断是否为微信环境
  120. isWechat() {
  121. var ua = navigator.userAgent.toLowerCase()
  122. var isWXWork = ua.match(/wxwork/i) == 'wxwork'
  123. var isWeixin = !isWXWork && ua.match(/MicroMessenger/i) == 'micromessenger'
  124. return isWeixin
  125. },
  126. getCode() {
  127. const appid = config.appid
  128. let loc_href = encodeURIComponent(window.location.href);
  129. let mainstate = Math.random()
  130. let wxUrl = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${loc_href}&response_type=code&scope=snsapi_base&state=${mainstate}#wechat_redirect`;
  131. window.location.href = wxUrl;
  132. },
  133. getUrlCode(name) {
  134. return new URL(window.location.href).searchParams.get(name + '')
  135. },
  136. getOpenidAndUserinfo(code){
  137. loginWx({
  138. code: code
  139. }).then(res => {
  140. const {
  141. name,
  142. customerVo,
  143. token,
  144. } = res
  145. uni.setStorageSync('openId', openId)
  146. const userInfo = uni.getStorageSync('userInfo')
  147. if (token) { // 登录成功 后更新用户信息
  148. uni.setStorageSync('accessToken', token)
  149. uni.setStorageSync('name', name)
  150. this.name = name
  151. // uni.setStorageSync('userInfo', customerVo)
  152. // 设置默认地址
  153. // addressFind().then(addrList => {
  154. // const defaultAddrIndex = addrList.findIndex(item => item.defaultFlag === 1);
  155. // defaultAddrIndex !== -1 && uni.setStorageSync('currentBuyerAddr', addrList[
  156. // defaultAddrIndex]);
  157. // })
  158. }
  159. if (!token) { // 未登录过
  160. // const channel = getUrlParamsNormal('channel')
  161. // if (channel === 'qrcode') { // 扫码进入的页面
  162. // uni.redirectTo({
  163. // url: '/pages/card/cardPhysical/index'
  164. // })
  165. // } else { // 进入登录
  166. // uni.redirectTo({
  167. // url: '/pages/login/index'
  168. // })
  169. // }
  170. uni.switchTab({
  171. url: '/pages/user/index'
  172. })
  173. }
  174. })
  175. },
  176. changeTabbar() {
  177. uni.setTabBarStyle({
  178. color: '#9EA3B1',
  179. selectedColor: '#0D121A',
  180. backgroundColor: '#FFF'
  181. })
  182. },
  183. toOrder(item) {
  184. this.$router.push({
  185. path: '/pages/order/index?status=' + item.value
  186. })
  187. },
  188. outLogin(){
  189. logout().then(res => {
  190. uni.removeStorageSync('accessToken')
  191. uni.removeStorageSync('name')
  192. this.name = ''
  193. this.token = ''
  194. })
  195. }
  196. },
  197. created() {
  198. },
  199. mounted() {
  200. },
  201. }
  202. </script>
  203. <style lang='scss' scoped>
  204. .my {
  205. width: 100%;
  206. // height: 100%;
  207. display: flex;
  208. flex-direction: column;
  209. position: absolute;
  210. top: 0;
  211. bottom: 0;
  212. background-size: contain !important;
  213. background-repeat: no-repeat !important;
  214. background-position: top;
  215. .title {
  216. padding: 16rpx 32rpx;
  217. image {
  218. height: 56rpx;
  219. }
  220. }
  221. .news {
  222. padding: 64rpx 48rpx 0;
  223. display: flex;
  224. align-items: center;
  225. image {
  226. width: 104rpx;
  227. height: 104rpx;
  228. background-color: aqua;
  229. border-radius: 50%;
  230. }
  231. .phone {
  232. font-weight: bold;
  233. font-size: 44rpx;
  234. color: #0D121A;
  235. margin-left: 32rpx;
  236. }
  237. }
  238. .content {
  239. padding: 0 24rpx;
  240. margin-top: 40rpx;
  241. box-sizing: content-box;
  242. }
  243. .more {
  244. width: 32rpx;
  245. height: 32rpx;
  246. }
  247. .order-wrap {
  248. width: 100%;
  249. display: flex;
  250. flex-direction: column;
  251. align-items: center;
  252. .unpay {
  253. // box-sizing: border-box;
  254. width: 638rpx;
  255. background: #FFEEE2;
  256. border-radius: 24rpx 24rpx 0rpx 0rpx;
  257. border: 2rpx solid #FFFEFD;
  258. padding: 16rpx 18rpx 16rpx 16rpx;
  259. display: flex;
  260. justify-content: space-between;
  261. align-items: center;
  262. .left {
  263. display: flex;
  264. align-items: center;
  265. image {
  266. width: 48rpx;
  267. height: 48rpx;
  268. }
  269. .tip {
  270. font-size: 24rpx;
  271. color: #FF7441;
  272. margin-left: 14rpx;
  273. text {
  274. font-weight: bold;
  275. }
  276. }
  277. }
  278. .right {
  279. width: 120rpx;
  280. height: 44rpx;
  281. font-weight: 500;
  282. background: #FF7441;
  283. border-radius: 24rpx;
  284. font-size: 24rpx;
  285. color: #FFFFFF;
  286. text-align: center;
  287. line-height: 44rpx;
  288. }
  289. }
  290. .order {
  291. padding: 32rpx 32rpx 40rpx;
  292. width: 100%;
  293. box-sizing: border-box;
  294. height: 260rpx;
  295. background: linear-gradient(180deg, #DEF5FD 0%, #FFFFFF 100%);
  296. border-radius: 32rpx;
  297. border: 2rpx solid #FFFFFF;
  298. .order_top {
  299. display: flex;
  300. justify-content: space-between;
  301. align-items: center;
  302. .mytt {
  303. font-weight: 500;
  304. font-size: 32rpx;
  305. color: #0D121A;
  306. }
  307. .myall {
  308. font-weight: 400;
  309. font-size: 26rpx;
  310. color: #0D121A;
  311. display: flex;
  312. align-items: center;
  313. .all {
  314. margin-right: 8rpx;
  315. }
  316. }
  317. }
  318. .order-box {
  319. display: flex;
  320. justify-content: space-between;
  321. align-items: center;
  322. margin-top: 48rpx;
  323. .order-box-item {
  324. display: flex;
  325. flex-direction: column;
  326. align-items: center;
  327. width: 128rpx;
  328. image {
  329. width: 64rpx;
  330. height: 64rpx;
  331. }
  332. .name {
  333. font-size: 24rpx;
  334. color: #0D121A;
  335. margin-top: 16rpx;
  336. }
  337. }
  338. }
  339. }
  340. }
  341. .cantact {
  342. width: 100%;
  343. height: 112rpx;
  344. background: #FFFFFF;
  345. border-radius: 24rpx;
  346. display: flex;
  347. justify-content: space-between;
  348. align-items: center;
  349. padding: 24rpx 32rpx;
  350. margin-top: 24rpx;
  351. .canl {
  352. display: flex;
  353. align-items: center;
  354. image {
  355. margin-right: 24rpx;
  356. width: 64rpx;
  357. height: 64rpx;
  358. }
  359. }
  360. }
  361. .outline {
  362. width: 622rpx;
  363. height: 96rpx;
  364. border-radius: 36rpx;
  365. border: 4rpx solid #E2E4EB;
  366. font-size: 28rpx;
  367. color: #0D121A;
  368. text-align: center;
  369. line-height: 96rpx;
  370. margin: 48rpx auto;
  371. }
  372. }
  373. </style>