| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791 |
- <template>
- <view style="padding-bottom: 80upx">
- <view class="u-flex padding-lr bg padding-top">
- <view class="u-m-r-10">
- <image :src="avatar" style="width: 100rpx; height: 100rpx; border-radius: 100rpx" @click="goNav('/my/store/index')"></image>
- </view>
- <view class="u-flex-1 u-m-l-10" v-if="!isLogin">
- <view class="u-font-18 text-bold">
- <view class="margin-left-sm margin-top-xs">
- <view class="flex align-end" style="display: flex; align-items: center">
- {{ userName }}
- <view class="status" v-if="shop" @click="changePutaWayFlag">
- <image
- :src="shop.putawayFlag == 0 ? '../../static/images/index/shangban.png' : '../../static/images/index/dayang.png'"
- style="width: 54rpx; height: 54rpx"
- ></image>
- {{ shop.putawayFlag == 0 ? '营业' : '关门' }}
- </view>
- </view>
- </view>
- </view>
- </view>
- <view v-else class="text-xl u-p-l-20 text-bold" @click="goLogin('/pages/my/loginphone')">登录</view>
- </view>
- <view class="flex align-center padding-left">
- <image src="../../static/images/img/data.png" style="width: 26upx; height: 26upx"></image>
- <view class="margin-left-xs flex align-center" style="color: #999999">
- <view @click="bindData(1)">{{ startTime ? startTime : '开始时间' }}</view>
- 至
- <view @click="bindData(2)">{{ endTime ? endTime : '结束时间' }}</view>
- </view>
- </view>
- <view class="flex align-center box justify-between text-center">
- <view @click="goNav('/my/other/cashList')">
- ¥
- <text class="text-bold text-xl">{{ allMoney ? allMoney : '0' }}</text>
- <view>总收益</view>
- </view>
- <view class="">
- <text class="text-bold text-xl">{{ allCount ? allCount : '0' }}</text>
- <view>总销量</view>
- </view>
- <view @click="goNav('/my/store/pingjia')">
- <text class="text-bold text-xl">{{ countTakingByUserId ? countTakingByUserId : '0' }}</text>
- <view>用户评价</view>
- </view>
- <!-- <view class="">
- <text class="text-bold text-xl">{{putaway+soldOut}}</text>
- <view>用户发布</view>
- </view> -->
- </view>
- <view class="padding">
- <view class="text-bold text-lg margin-bottom-sm">订单数据</view>
- <view class="orderbox">
- <view class="">
- ¥
- <text class="text-bold text-xl">{{ orderMoney ? orderMoney : '0' }}</text>
- <view class="margin-top-xs">订单收入</view>
- </view>
- <view class="">
- <text class="text-bold text-xl">{{ sumCountOrder ? sumCountOrder : '0' }}</text>
- <view class="margin-top-xs">总订单数</view>
- </view>
- <view class="">
- ¥
- <text class="text-bold text-xl">{{ refundMoney ? refundMoney : '0' }}</text>
- <view class="margin-top-xs">退款金额</view>
- </view>
- <view class="">
- <text class="text-bold text-xl">{{ countByUserId ? countByUserId : '0' }}</text>
- <view class="margin-top-xs">访客人数</view>
- </view>
- </view>
- </view>
- <view style="padding: 0upx 30upx">
- <view class="text-bold text-lg margin-bottom-sm flex justify-between">
- <view>订单管理</view>
- <view @click="goDetail(1)">
- <text style="color: #666666; font-size: 26upx; margin-right: 10upx">查看全部</text>
- <image src="../../static/images/my/right.png" style="width: 12upx; height: 20upx"></image>
- </view>
- </view>
- <view class="orderbox">
- <!-- <view class="">
- <text class="text-bold text-xl">{{i1}}</text>
- <view class="margin-top-xs">待付款</view>
- </view> -->
- <view class="">
- <text class="text-bold text-xl">{{ i5 }}</text>
- <view class="margin-top-xs">待接单</view>
- </view>
- <view class="">
- <text class="text-bold text-xl">{{ i2 }}</text>
- <view class="margin-top-xs">制作中</view>
- </view>
- <view class="">
- <text class="text-bold text-xl">{{ i3 }}</text>
- <view class="margin-top-xs">待取餐</view>
- </view>
- <view class="">
- <text class="text-bold text-xl">{{ i4 }}</text>
- <view class="margin-top-xs">已完成</view>
- </view>
- </view>
- </view>
- <view class="padding">
- <view class="text-bold text-lg margin-bottom-sm flex justify-between">
- <view>我的商品</view>
- <view @click="goDetail(2)">
- <text style="color: #666666; font-size: 26upx; margin-right: 10upx">查看全部</text>
- <image src="../../static/images/my/right.png" style="width: 12upx; height: 20upx"></image>
- </view>
- </view>
- <view class="orderbox">
- <view class="">
- <text class="text-bold text-xl">{{ putawayCount }}</text>
- <view class="margin-top-sm">上架中</view>
- </view>
- <view class="">
- <text class="text-bold text-xl">{{ soldoutCount }}</text>
- <view class="margin-top-sm">已下架</view>
- </view>
- <view @click="bindFb()">
- <image src="../../static/images/index/add.png" style="width: 46upx; height: 46upx"></image>
- <view class="margin-top-xs">添加商品</view>
- </view>
- </view>
- </view>
- <u-popup v-model="Authorization" mode="center" close-icon="close-circle" close-icon-pos="top-right" close-icon-color="#8f9298" close-icon-size="50">
- <view class="contentview">
- <view class="title">隐私保护指引</view>
- <view class="des" @click="openPrivacyContract">
- 在使用当前小程序服务之前,请仔细阅读
- <text style="color: #ff7f00">{{ privacyContractName }}</text>
- 。如你同意{{ privacyContractName }},请点击“同意”开始使用。
- </view>
- <view class="btns">
- <button class="item reject" @click="exitMiniProgram">拒绝</button>
- <button id="agree-btn" class="item agree" open-type="agreePrivacyAuthorization" @agreeprivacyauthorization="handleAgreePrivacyAuthorization">同意</button>
- </view>
- </view>
- </u-popup>
- <!-- 开始时间 -->
- <u-picker v-model="startshow" mode="time" :params="paramsStart" @confirm="startData"></u-picker>
- <!-- 结束时间 -->
- <u-picker v-model="endshow" mode="time" :params="paramsEnd" @confirm="endData"></u-picker>
- </view>
- </template>
- <script>
- import { encrypt, decrypt, urlSafeBase64Decode, urlSafeBase64Encode } from '@/utils/cryptojs.js'
- export default {
- data() {
- return {
- Authorization: false,
- privacyContractName: '',
- avatar: '../../static/logo.png',
- isLogin: true,
- userName: '匿名',
- startshow: false,
- endshow: false,
- paramsStart: {
- year: true,
- month: true,
- day: true,
- hour: false,
- minute: false,
- second: false
- },
- paramsEnd: {
- year: true,
- month: true,
- day: true,
- hour: false,
- minute: false,
- second: false
- },
- startTime: '',
- endTime: '',
- allMoney: 0, //总收益
- allCount: 0, //总销量
- countTakingByUserId: 0, //用户评价数
- orderMoney: 0, //订单收入
- sumCountOrder: 0, //总订单数
- refundMoney: 0, //退款金额
- countByUserId: 0, //访客人数
- i1: 0, //待付款
- i2: 0, //制作中
- i3: 0, //待取餐
- i4: 0, //已完成
- i5: 0, //商家待接单
- putawayCount: 0, //上架中
- soldoutCount: 0, //下架中
- page: 1,
- limit: 10,
- longitude: '',
- latitude: '',
- userId: '',
- shop: '',
- arr: [],
- errCount: 0,
- messageConfiguration: '',
- timer: null
- }
- },
- onLoad() {
- this.userId = uni.getStorageSync('userId')
- if (this.userId) {
- this.getFb()
- }
- this.$Request.getT('/app/common/type/354').then((res) => {
- //订单取消通知
- if (res.code == 0) {
- if (res.data && res.data.value) {
- this.arr.push(res.data.value)
- }
- }
- })
- this.$Request.getT('/app/common/type/353').then((res) => {
- //订单取消通知
- if (res.code == 0) {
- if (res.data && res.data.value) {
- this.arr.push(res.data.value)
- }
- }
- })
- this.$Request.getT('/app/common/type/352').then((res) => {
- //新订单通知
- if (res.code == 0) {
- if (res.data && res.data.value) {
- this.arr.push(res.data.value)
- }
- }
- })
- // #ifdef MP-WEIXIN
- try {
- let that = this
- wx.getPrivacySetting({
- success: (res) => {
- console.log('是否需要授权:', res.needAuthorization, '隐私协议的名称为:', res.privacyContractName)
- if (res.needAuthorization) {
- that.privacyContractName = res.privacyContractName
- // this.$refs.popusAuthorization.open();
- that.Authorization = true
- }
- },
- fail: () => {},
- complete: () => {}
- })
- } catch (e) {
- //TODO handle the exception
- }
- // #endif
- },
- onShow() {
- this.userId = uni.getStorageSync('userId')
- if (this.userId) {
- this.isLogin = false
- this.getUserInfo()
- this.getFb()
- // this.getTodayOrder()
- this.getcity()
- this.getShopInfo()
- // #ifdef MP-WEIXIN
- //订阅
- if (!uni.getStorageSync('sendindexMsg')) {
- this.openMsg()
- }
- // #endif
- this.getSetData()
- } else {
- this.isLogin = true
- // this.userName = '匿名'
- this.avatar = '../../static/logo.png'
- this.allMoney = 0 //总收益
- this.putawayCount = 0 //上架中
- this.soldoutCount = 0 //下架中
- this.allCount = 0 //总销量
- this.countTakingByUserId = 0 //用户评价
- this.orderMoney = 0 //订单收入
- this.sumCountOrder = 0 //总订单数
- this.refundMoney = 0 //退款金额
- this.countByUserId = 0 //访客人数
- this.i1 = 0 //待付款
- this.i3 = 0 //待取餐
- this.i2 = 0 //制作中
- this.i4 = 0 //已完成
- this.i5 = 0 //商家待接单
- }
- },
- onHide() {
- if (this.timer) {
- clearInterval(this.timer)
- }
- },
- methods: {
- getSetData() {
- // 获取订阅消息配置
- let data = {
- shopId: uni.getStorageSync('shopId')
- }
- this.$Request.getT('/app/goods/selectGoodShop', data).then((res) => {
- // console.log(res, '888')
- if (res.code == 0) {
- this.messageConfiguration = res.data.messageConfiguration
- if (this.messageConfiguration == 0) {
- this.timer = setInterval(() => {
- // 订单消息提醒
- let data = {
- shopIds: this.$queue.getData('shopId')
- }
- this.$Request.post('/admin/ordermessage/selectReadFlagCount', data).then((res) => {
- // console.log(res, '999')
- if (res.code === 0) {
- if (res.data > 0) {
- if (this.errCount != res.data) {
- this.errCount = res.data
- this.aplayAudio()
- uni.showModal({
- title: '消息',
- content: '有' + res.data + '条订单,请前往订单中心处理。',
- success: (ret) => {
- if (ret.confirm) {
- uni.switchTab({
- url: '/pages/order/index'
- })
- } else {
- console.log('else', ret)
- this.defineCallBack()
- }
- }
- })
- // this.chatNum = data.data
- }
- } else {
- this.errCount = 0
- }
- }
- })
- }, 10000)
- }
- }
- })
- },
- // 打开隐私协议页面
- openPrivacyContract() {
- let that = this
- wx.openPrivacyContract({
- fail: () => {
- that.$queue.showToast('遇到错误无法打开!')
- }
- })
- },
- // 拒绝隐私协议
- exitMiniProgram() {
- // 直接退出小程序
- wx.exitMiniProgram()
- },
- // 同意隐私协议
- handleAgreePrivacyAuthorization() {
- this.Authorization = false
- },
- openMsg() {
- var that = this
- wx.getSetting({
- withSubscriptions: true, //是否获取用户订阅消息的订阅状态,默认false不返回
- success(ret) {
- if (ret.subscriptionsSetting.itemSettings) {
- uni.setStorageSync('sendindexMsg', true)
- uni.openSetting({
- // 打开设置页
- success(rea) {
- console.log(rea.authSetting)
- }
- })
- } else {
- // 用户没有点击“总是保持以上,不再询问”则每次都会调起订阅消息
- uni.setStorageSync('sendindexMsg', false)
- uni.showModal({
- title: '提示',
- content: '为了更好的体验,请绑定消息推送',
- confirmText: '确定',
- cancelText: '取消',
- success: function (res) {
- if (res.confirm) {
- uni.requestSubscribeMessage({
- tmplIds: that.arr,
- success(re) {
- // console.log(re,'**********')
- var datas = JSON.stringify(re)
- if (datas.indexOf('accept') != -1) {
- console.log(re)
- }
- },
- fail: (res) => {
- console.log(res)
- }
- })
- that.showModal = false
- } else if (res.cancel) {
- that.showModal = true
- }
- }
- })
- }
- }
- })
- },
- //切换店铺状态
- changePutaWayFlag() {
- if (this.shop.putawayFlag == 0) {
- uni.showModal({
- title: '提示',
- content: '确定要打烊了吗?',
- showCancel: true,
- cancelText: '取消',
- confirmText: '确定',
- success: (res) => {
- if (res.confirm) {
- this.shop.putawayFlag = 1
- this.updateShopInfo()
- }
- },
- fail: () => {},
- complete: () => {}
- })
- } else {
- this.shop.putawayFlag = 0
- this.updateShopInfo()
- }
- },
- updateShopInfo() {
- this.$Request.postJsonA('/app/shop/updateShopMessage', this.shop).then((res) => {
- if (res.code == 0) {
- this.getShopInfo()
- } else {
- // this.shop.putawayFlag = 1
- uni.showModal({
- title: '提示',
- content: res.msg,
- success: function (res) {
- if (res.confirm) {
- } else if (res.cancel) {
- }
- }
- })
- this.getShopInfo()
- }
- })
- },
- getShopInfo() {
- if (this.$queue.getData('shopId')) {
- let data = {
- shopId: this.$queue.getData('shopId')
- }
- this.$Request.getA('/app/shop/selectShopMessage', data).then((res) => {
- if (res.code == 0) {
- uni.hideLoading()
- this.shop = res.data
- }
- })
- }
- },
- aplayAudio() {
- // const audio = document.getElementById('audio')
- // audio.play()
- // console.log('语音提示')
- const innerAudioContext = uni.createInnerAudioContext()
- innerAudioContext.autoplay = true
- // innerAudioContext.src ='../../static/mpc/order.mp3';
- innerAudioContext.src = 'https://pw.xianmxkj.com/file/uploadPath/2022/01/19/0753211f78d718d44ee6372e33eae9ee.mp3'
- innerAudioContext.onPlay(() => {
- console.log('开始播放')
- })
- innerAudioContext.onError((res) => {
- console.log(res.errMsg)
- console.log(res.errCode)
- })
- },
- defineCallBack() {
- let that = this
- let data = {
- shopIds: that.$queue.getData('shopId')
- }
- that.$Request.post('/admin/ordermessage/allcheckOrderMessage', data).then((res) => {
- if (res.code === 0) {
- that.errCount = 0
- }
- })
- },
- getcity() {
- let that = this
- uni.getLocation({
- type: 'wgs84',
- success: function (res) {
- // console.log('当前位置的经度:' + res.longitude);
- // console.log('当前位置的纬度:' + res.latitude);
- that.latitude = res.latitude
- that.longitude = res.longitude
- }
- })
- },
- //获取用户发布
- getFb() {
- let data = {
- startTime: this.startTime,
- endTime: this.endTime,
- shopId: this.$queue.getData('shopId')
- }
- this.$Request.getA('/app/shop/shopHomePage', data).then((res) => {
- if (res.code == 0) {
- this.allMoney = res.data.allMoney //总收益
- this.putawayCount = res.data.putawayCount //上架中
- this.soldoutCount = res.data.soldoutCount //下架中
- this.allCount = res.data.allCount //总销量
- this.countTakingByUserId = res.data.countTakingByUserId //用户评价
- this.orderMoney = res.data.orderMoney //订单收入
- this.sumCountOrder = res.data.sumCountOrder //总订单数
- this.refundMoney = res.data.refundMoney //退款金额
- this.countByUserId = res.data.countByUserId //访客人数
- this.i1 = res.data.i1 //待付款
- this.i3 = res.data.i3 //待取餐
- this.i2 = res.data.i2 //制作中
- this.i4 = res.data.i4 //已完成
- this.i5 = res.data.i5 //商家待接单
- }
- })
- },
- goDetail(index) {
- // #ifdef MP-WEIXIN
- if (uni.getStorageSync('sendindexMsg')) {
- uni.requestSubscribeMessage({
- tmplIds: this.arr,
- success(re) {
- // console.log(re,'**********')
- var datas = JSON.stringify(re)
- if (datas.indexOf('accept') != -1) {
- console.log(re)
- }
- },
- fail: (res) => {
- console.log(res)
- }
- })
- }
- // #endif
- if (index == 1) {
- uni.switchTab({
- url: '/pages/order/index'
- })
- } else if (index == 2) {
- uni.navigateTo({
- url: '/my/store/addgood'
- })
- }
- },
- bindFb() {
- let userId = uni.getStorageSync('userId')
- if (userId) {
- uni.navigateTo({
- url: '/my/publish/goods'
- })
- } else {
- uni.showModal({
- title: '提示',
- content: '您还未登录,请先登录',
- success: function (res) {
- if (res.confirm) {
- // console.log('用户点击确定');
- uni.navigateTo({
- url: '/pages/my/loginphone'
- })
- } else if (res.cancel) {
- // console.log('用户点击取消');
- }
- }
- })
- }
- },
- //时间弹框开关
- bindData(index) {
- if (index == 1) {
- this.startshow = true
- } else if (index == 2) {
- this.endshow = true
- }
- },
- //开始时间
- startData(e) {
- this.startTime = e.year + '-' + e.month + '-' + e.day
- },
- // 结束时间
- endData(e) {
- this.endTime = e.year + '-' + e.month + '-' + e.day
- this.getFb()
- },
- goNav(e, name) {
- if (this.userId) {
- // #ifdef MP-WEIXIN
- if (uni.getStorageSync('sendindexMsg')) {
- uni.requestSubscribeMessage({
- tmplIds: this.arr,
- success(re) {
- // console.log(re,'**********')
- var datas = JSON.stringify(re)
- if (datas.indexOf('accept') != -1) {
- console.log(re)
- }
- },
- fail: (res) => {
- console.log(res)
- }
- })
- }
- // #endif
- uni.navigateTo({
- url: e
- })
- } else {
- uni.showModal({
- title: '提示',
- content: '您还未登录,请先登录',
- success: function (res) {
- if (res.confirm) {
- console.log('用户点击确定')
- uni.navigateTo({
- url: '/pages/my/loginphone'
- })
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- }
- })
- }
- },
- getUserInfo() {
- console.log(',,,')
- this.$Request.getA('/sys/user/info').then((res) => {
- console.log(res, 'kk')
- if (res.code == 0) {
- // this.userName = res.user.userEntity.userName
- this.userName = res.user.shopList[0].shopName
- // this.avatar = res.user.userEntity.avatar ? res.user.userEntity.avatar : '../../static/logo.png'
- this.avatar = res.user.shopList[0].shopCover ? res.user.shopList[0].shopCover : '../../static/logo.png'
- this.$queue.setData('userId', res.user.userId)
- this.$queue.setData('shopId', res.user.shopList[0].shopId)
- this.$queue.setData('shopTypeId', res.user.shopList[0].shopTypeId)
- this.$queue.setData('mobile', res.user.mobile)
- if (res.user.userEntity) {
- this.$queue.setData('shopUserName', res.user.userEntity.userName)
- }
- }
- })
- },
- goLogin(e) {
- uni.navigateTo({
- url: e
- })
- }
- }
- }
- </script>
- <style lang="scss">
- page {
- background-color: #ffffff;
- }
- .bg {
- background-color: #ffffff;
- }
- .box {
- width: 690upx;
- margin: 0 auto;
- height: 120rpx;
- background: rgba(255, 141, 26, 0.6);
- border-radius: 16upx 16upx 0px 0px;
- color: #333333;
- padding: 0upx 30upx;
- margin-top: 20upx;
- }
- .orderbox {
- width: 690upx;
- margin: 0 auto;
- height: 153upx;
- background: #fafafa;
- border-radius: 16upx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- text-align: center;
- padding: 0upx 30upx;
- }
- .privacy {
- position: fixed;
- top: 0;
- right: 0;
- bottom: 0;
- left: 0;
- background: rgba(0, 0, 0, 0.5);
- z-index: 9999999;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .contentview {
- width: 632rpx;
- padding: 48rpx;
- box-sizing: border-box;
- background: #fff;
- border-radius: 16rpx;
- }
- .contentview .title {
- text-align: center;
- color: #333;
- font-weight: bold;
- font-size: 32rpx;
- }
- .contentview .des {
- font-size: 26rpx;
- color: #666;
- margin-top: 40rpx;
- text-align: justify;
- line-height: 1.6;
- }
- .contentview .des .link {
- color: #07c160;
- text-decoration: underline;
- }
- button::after {
- border: none;
- }
- .btns {
- margin-top: 48rpx;
- display: flex;
- }
- .btns .item {
- justify-content: space-between;
- width: 244rpx;
- height: 80rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- border-radius: 16rpx;
- box-sizing: border-box;
- border: none;
- }
- .btns .reject {
- background: #f4f4f5;
- color: #909399;
- }
- .btns .agree {
- background: #07c160;
- color: #fff;
- }
- .status {
- display: flex;
- justify-content: space-evenly;
- align-items: center;
- margin-left: auto;
- width: 215rpx;
- height: 93rpx;
- border: 2rpx solid #0061ff;
- border-radius: 10rpx;
- }
- </style>
|