index.vue 9.6 KB

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