123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411 |
- <!-- 我的 -->
- <template>
- <view class="my" :style="{ background: 'url(' + bgImg + ') #F4F5F9' }">
- <view class="title">
- <image :src="logoImg" mode="heightFix"></image>
- </view>
- <view class="news">
- <image :src="avatar"></image>
- <view v-if="name" class="phone">{{name}}</view>
- <view v-else class="phone" @click="toLogin()">点击登录</view>
- </view>
- <view class="content">
- <view class="order-wrap">
- <!-- <view class="unpay">
- <view class="left">
- <image :src="tongzhi"></image>
- <view class="tip">您有1笔订单待付款<text>09:34</text>后取消</view>
- </view>
- <view class="right">去付款</view>
- </view> -->
- <view class="order">
- <view class="order_top">
- <text class="mytt">我的订单</text>
- <view class="myall" @click="toOrder">
- <text class="all">全部</text>
- <image class="more" :src="moreImg"></image>
- </view>
- </view>
- <view class="order-box">
- <view class="order-box-item" v-for="(item, index) in orderList" :key="index" @click="toOrder(item)">
- <image :src="item.icon"></image>
- <text class="name">{{ item.label }}</text>
- </view>
- </view>
- </view>
- </view>
- <view class="cantact">
- <view class="canl">
- <image :src="cantact"></image>
- <text>联系客服</text>
- </view>
- <image class="more" :src="moreImg"></image>
- </view>
- <view class="outline" @click="outLogin()">退出登录</view>
- </view>
- </view>
- </template>
- <script>
- import config from '@/config'
- import { loginWx,logout } from '@/apis/user.js'
- export default {
- components: {},
- data() {
- return {
- name: uni.getStorageSync('name'),
- token: uni.getStorageSync('token'),
- code: '',
- bgImg: "https://ovp-shop.oss-cn-hangzhou.aliyuncs.com/static/9dshop/bg_top%403x.png",
- logoImg: "https://ovp-shop.oss-cn-hangzhou.aliyuncs.com/static/9dshop/img_logo%403x.png",
- tongzhi: "https://ovp-shop.oss-cn-hangzhou.aliyuncs.com/static/9dshop/ic_tongzhi%403x.png",
- moreImg: "https://ovp-shop.oss-cn-hangzhou.aliyuncs.com/static/9dshop/ic_more%403x.png",
- cantact: "https://ovp-shop.oss-cn-hangzhou.aliyuncs.com/static/9dshop/ic_kefurexian%403x.png",
- avatar: '',
- orderList: [
- {
- value: 1,
- label: '全部',
- icon: "https://ovp-shop.oss-cn-hangzhou.aliyuncs.com/static/9dshop/ic_daifukuan%403x.png"
- },
- {
- value: 2,
- label: '待付款',
- icon: "https://ovp-shop.oss-cn-hangzhou.aliyuncs.com/static/9dshop/ic_daifukuan%403x.png"
- },
- {
- value: 3,
- label: '拍摄中',
- icon: "https://ovp-shop.oss-cn-hangzhou.aliyuncs.com/static/9dshop/ic_daifukuan%403x.png"
- },
- {
- value: 4,
- label: '已完成',
- icon: "https://ovp-shop.oss-cn-hangzhou.aliyuncs.com/static/9dshop/ic_diankaguanli%403x.png"
- }
- ]
- };
- },
- computed: {},
- watch: {},
- onLoad() {
-
- let token = uni.getStorageSync('token')
- if(!token){
- this.toLogin()
- }
- // if(code !== null || code !== "") {
- // this.getOpenidAndUserinfo(code)
- // }
- },
- onShow() {
- this.changeTabbar()
- },
- methods: {
- toLogin() {
- let isWX = this.isWechat()
- if (isWX) {
- // let code = this.getUrlCode('code')
- let code = '001t0H000xuK7U'
- uni.showToast({
- title: code,
- })
- if (code !== null && code !== undefined) {
- this.code = code
- this.getOpenidAndUserinfo(code)
- } else {
- this.getCode()
- }
- }
- },
- // 判断是否为微信环境
- isWechat() {
- var ua = navigator.userAgent.toLowerCase()
- var isWXWork = ua.match(/wxwork/i) == 'wxwork'
- var isWeixin = !isWXWork && ua.match(/MicroMessenger/i) == 'micromessenger'
- return isWeixin
- },
- getCode() {
- const appid = config.appid
- let loc_href = encodeURIComponent(window.location.href);
- let mainstate = Math.random()
- 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`;
- window.location.href = wxUrl;
- },
- getUrlCode(name) {
- return new URL(window.location.href).searchParams.get(name + '')
- },
- getOpenidAndUserinfo(code){
- loginWx({
- code: code
- }).then(res => {
- const {
- name,
- customerVo,
- token,
- } = res
- uni.setStorageSync('openId', openId)
- const userInfo = uni.getStorageSync('userInfo')
- if (token) { // 登录成功 后更新用户信息
- uni.setStorageSync('accessToken', token)
- uni.setStorageSync('name', name)
- this.name = name
- // uni.setStorageSync('userInfo', customerVo)
- // 设置默认地址
- // addressFind().then(addrList => {
- // const defaultAddrIndex = addrList.findIndex(item => item.defaultFlag === 1);
- // defaultAddrIndex !== -1 && uni.setStorageSync('currentBuyerAddr', addrList[
- // defaultAddrIndex]);
- // })
- }
- if (!token) { // 未登录过
- // const channel = getUrlParamsNormal('channel')
- // if (channel === 'qrcode') { // 扫码进入的页面
- // uni.redirectTo({
- // url: '/pages/card/cardPhysical/index'
- // })
- // } else { // 进入登录
- // uni.redirectTo({
- // url: '/pages/login/index'
- // })
- // }
- uni.switchTab({
- url: '/pages/user/index'
- })
- }
- })
- },
- changeTabbar() {
- uni.setTabBarStyle({
- color: '#9EA3B1',
- selectedColor: '#0D121A',
- backgroundColor: '#FFF'
- })
- },
- toOrder(item) {
- this.$router.push({
- path: '/pages/order/index?status=' + item.value
- })
- },
- outLogin(){
- logout().then(res => {
- uni.removeStorageSync('accessToken')
- uni.removeStorageSync('name')
- this.name = ''
- this.token = ''
- })
- }
- },
- created() {
- },
- mounted() {
- },
- }
- </script>
- <style lang='scss' scoped>
- .my {
- width: 100%;
- // height: 100%;
- display: flex;
- flex-direction: column;
- position: absolute;
- top: 0;
- bottom: 0;
- background-size: contain !important;
- background-repeat: no-repeat !important;
- background-position: top;
- .title {
- padding: 16rpx 32rpx;
- image {
- height: 56rpx;
- }
- }
- .news {
- padding: 64rpx 48rpx 0;
- display: flex;
- align-items: center;
- image {
- width: 104rpx;
- height: 104rpx;
- background-color: aqua;
- border-radius: 50%;
- }
- .phone {
- font-weight: bold;
- font-size: 44rpx;
- color: #0D121A;
- margin-left: 32rpx;
- }
- }
- .content {
- padding: 0 24rpx;
- margin-top: 40rpx;
- box-sizing: content-box;
- }
- .more {
- width: 32rpx;
- height: 32rpx;
- }
- .order-wrap {
- width: 100%;
- display: flex;
- flex-direction: column;
- align-items: center;
- .unpay {
- // box-sizing: border-box;
- width: 638rpx;
- background: #FFEEE2;
- border-radius: 24rpx 24rpx 0rpx 0rpx;
- border: 2rpx solid #FFFEFD;
- padding: 16rpx 18rpx 16rpx 16rpx;
- display: flex;
- justify-content: space-between;
- align-items: center;
- .left {
- display: flex;
- align-items: center;
- image {
- width: 48rpx;
- height: 48rpx;
- }
- .tip {
- font-size: 24rpx;
- color: #FF7441;
- margin-left: 14rpx;
- text {
- font-weight: bold;
- }
- }
- }
- .right {
- width: 120rpx;
- height: 44rpx;
- font-weight: 500;
- background: #FF7441;
- border-radius: 24rpx;
- font-size: 24rpx;
- color: #FFFFFF;
- text-align: center;
- line-height: 44rpx;
- }
- }
- .order {
- padding: 32rpx 32rpx 40rpx;
- width: 100%;
- box-sizing: border-box;
- height: 260rpx;
- background: linear-gradient(180deg, #DEF5FD 0%, #FFFFFF 100%);
- border-radius: 32rpx;
- border: 2rpx solid #FFFFFF;
- .order_top {
- display: flex;
- justify-content: space-between;
- align-items: center;
- .mytt {
- font-weight: 500;
- font-size: 32rpx;
- color: #0D121A;
- }
- .myall {
- font-weight: 400;
- font-size: 26rpx;
- color: #0D121A;
- display: flex;
- align-items: center;
- .all {
- margin-right: 8rpx;
- }
- }
- }
- .order-box {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-top: 48rpx;
- .order-box-item {
- display: flex;
- flex-direction: column;
- align-items: center;
- width: 128rpx;
- image {
- width: 64rpx;
- height: 64rpx;
- }
- .name {
- font-size: 24rpx;
- color: #0D121A;
- margin-top: 16rpx;
- }
- }
- }
- }
- }
- .cantact {
- width: 100%;
- height: 112rpx;
- background: #FFFFFF;
- border-radius: 24rpx;
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 24rpx 32rpx;
- margin-top: 24rpx;
- .canl {
- display: flex;
- align-items: center;
- image {
- margin-right: 24rpx;
- width: 64rpx;
- height: 64rpx;
- }
- }
- }
- .outline {
- width: 622rpx;
- height: 96rpx;
- border-radius: 36rpx;
- border: 4rpx solid #E2E4EB;
- font-size: 28rpx;
- color: #0D121A;
- text-align: center;
- line-height: 96rpx;
- margin: 48rpx auto;
- }
- }
- </style>
|