| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621 |
- <template>
- <view class="home">
- <view class="nav">
- <view :style="{ paddingTop }">
- <view class="title" :style="[{ height }, { lineHeight: height }]">
- <view class="back" @click="goBack()">
- <u-icon name="arrow-left" color="#ffffff" size="22"></u-icon>
- </view>
- <text>打卡</text>
- </view>
- </view>
- </view>
- <view class="main">
- <view class="main-header">
- <view class="user-info">
- <image class="user-img" src="@/static/images/user.jpg" mode="scaleToFill" />
- <view class="info flex1 flex-column flex_1">
- <u-text :lines="1" size="32rpx" :bold="true" :text="nickName"></u-text>
- <u-text :lines="1" size="24rpx" :text="postName"></u-text>
- </view>
- </view>
- <view class="more" @click="showCheckList">
- <u-icon name="order" size="60rpx"></u-icon>
- <u-text :lines="1" size="24rpx" text="打卡记录"></u-text>
- </view>
- </view>
- <view class="main-form" v-if="!showList">
- <u-form :model="form" :rules="rules" ref="form" label-width="0">
- <u-form-item prop="punchVal" borderBottom customStyle="padding:40rpx 0 30rpx" @click="showCheckType = true">
- <view class="form-label flex_l">
- <view class="label-tag"></view>
- 打卡类型
- </view>
- <u-input
- :readonly="true"
- placeholder="请选择销售模式"
- v-model="form.punchVal"
- border="none"
- suffixIcon="arrow-down"
- suffixIconStyle="color:#CDCDCD"
- clearable
- customStyle="padding: 0 30rpx 0 12rpx"></u-input>
- </u-form-item>
- <u-form-item
- prop="targetName"
- borderBottom
- customStyle="padding:40rpx 0 30rpx"
- v-if="form.punchType > 10"
- @click="openSelectUser()">
- <view class="form-label flex_l">
- <view class="label-tag"></view>
- {{ selectLable(form.punchType) }}
- </view>
- <u-input
- :readonly="true"
- :placeholder="`请选择${selectLable(form.punchType)}`"
- v-model="form.targetName"
- border="none"
- suffixIcon="arrow-down"
- suffixIconStyle="color:#CDCDCD"
- clearable
- customStyle="padding: 0 30rpx 0 12rpx"></u-input>
- </u-form-item>
- <!-- 合作伙伴联系人 -->
- <u-form-item
- prop="partnerContactName"
- borderBottom
- customStyle="padding:40rpx 0 30rpx"
- v-if="form.punchType == 50 && form.targetId"
- @click="openPartnersConcat()">
- <view class="form-label flex_l">合作伙伴联系人</view>
- <u-input
- :readonly="true"
- placeholder="请选择合作伙伴联系人"
- v-model="form.partnerContactName"
- border="none"
- suffixIcon="arrow-down"
- suffixIconStyle="color:#CDCDCD"
- clearable
- customStyle="padding: 0 30rpx 0 12rpx"></u-input>
- </u-form-item>
- <!-- END -->
- </u-form>
- </view>
- <view class="main-container">
- <template v-if="!showList">
- <view class="btn" @click="checkIn">打卡</view>
- <view class="location">
- <u-text @click="getLocation" :lines="1" :block="true" align="center" size="32rpx" :text="address"></u-text>
- <u-loading-icon mode="circle" size="24rpx" :show="show"></u-loading-icon>
- </view>
- </template>
- <u-list height="calc(100vh - 410rpx)" @scrolltolower="scrolltolower" v-else>
- <u-list-item v-for="(item, index) in checkList" :key="index">
- <u-cell :title="item.punchTime" :label="item.punchLocation"></u-cell>
- </u-list-item>
- </u-list>
- </view>
- </view>
- <u-toast ref="uToast"></u-toast>
- <!-- <uni-file-picker file-mediatype="all" v-model="imageValue" @select="select" @progress="progress" @success="success"
- @fail="fail" ref="upload" limit="1">
- <view class="upload-btn">
- <u-icon name="plus-circle-fill" color="blue" size="28"></u-icon>
- </view>
- </uni-file-picker> -->
- <!-- 打卡类型 -->
- <u-picker
- :show="showCheckType"
- :columns="[checkTypeColumns]"
- keyName="value"
- @cancel="showCheckType = false"
- @confirm="pickCheckType"></u-picker>
- <!-- 选择经销商 -->
- <select-dealer ref="dealer" :distrId="form.punchType" dist @close="closeDealer($event)"></select-dealer>
- <!-- 选择客户 -->
- <select-customer ref="cust" @close="closeCust($event)"></select-customer>
- <!-- 选择合作伙伴 -->
- <select-partners ref="partners" @close="closePartners($event)"></select-partners>
- <select-partners-concat
- ref="partnersConcat"
- :queryParams="{ partnerId: form.targetId }"
- @close="closePartnersConcat($event)"></select-partners-concat>
- <u-notify ref="uNotify"></u-notify>
- <u-popup :show="shwoSuccess" mode="center" :safeAreaInsetBottom="false" overlayOpacity="0" round="10">
- <view class="tips-wrap">
- <u-image :src="form.punchImg" mode="scaleToFill" width="80vw" height="500px" />
- <view class="tips-content">
- <view class="success-icon-wrap">
- <u-icon name="checkmark-circle-fill" color="#409EFF" size="60"></u-icon>
- </view>
- <view class="tit">签到成功</view>
- <view class="content">
- <view class="mb20">{{ getNowTime() }}</view>
- <view class="mb20">{{ form.punchLocation }}</view>
- <view class="mb20">打卡人:{{ nickName }}</view>
- <view class="mb20">打卡类型:{{ form.punchVal }}</view>
- <view class="mb20" v-if="form.targetName">{{ form.punchVal }}名称:{{ form.targetName }}</view>
- </view>
- <view class="confirm">
- <u-button type="primary" text="确定" @click="shwoSuccess = false"></u-button>
- </view>
- </view>
- </view>
- </u-popup>
- </view>
- </template>
- <script>
- import { mapGetters } from 'vuex'
- import to from 'await-to-js'
- import api from '@/api/system'
- import SelectDealer from 'components/SelectDealer'
- import SelectCustomer from 'components/SelectCustomer'
- import SelectPartners from 'components/SelectPartners'
- import SelectPartnersConcat from 'components/SelectPartnersConcat'
- export default {
- components: {
- SelectDealer,
- SelectCustomer,
- SelectPartners,
- SelectPartnersConcat,
- },
- data() {
- return {
- shwoSuccess: false,
- height: '',
- paddingTop: '',
- address: '获取定位',
- showCheckType: false,
- form: {
- targetId: undefined, //经销商/代理商ID
- targetName: undefined, //经销商/代理商名称
- punchType: '', //打卡类型
- punchVal: '',
- punchLat: 0,
- punchLng: 0,
- punchLocation: '',
- punchImg: 'https://oms.dashoo.cn/weed1/5,01456eecb7e4a8',
- partnerContactId: null,
- partnerContactName: null,
- },
- show: false,
- imageValue: [],
- showList: false,
- checkList: [],
- queryForm: {
- pageNum: 1,
- pageSize: 10,
- },
- total: 0,
- checkTypeColumns: [
- {
- key: '10',
- value: '居家',
- },
- {
- key: '20',
- value: '客户',
- },
- {
- key: '30',
- value: '经销商',
- },
- { key: '40', value: '代理商' },
- { key: '50', value: '合作伙伴' },
- ],
- rules: {
- punchVal: [
- {
- required: true,
- trigger: ['blur', 'change'],
- message: '请选择打卡类型',
- },
- ],
- targetName: [
- {
- required: true,
- trigger: ['blur', 'change'],
- message: `请选择用户`,
- },
- ],
- },
- }
- },
- computed: {
- ...mapGetters(['nickName', 'postName']),
- },
- created() {
- this.getLocation()
- const navData = uni.getMenuButtonBoundingClientRect()
- this.height = navData.height + 'px'
- this.paddingTop = navData.top + 'px'
- },
- watch: {
- 'form.punchType'(val) {
- this.form.targetId = undefined
- this.form.targetName = undefined
- this.form.partnerContactId = null
- this.form.partnerContactName = null
- },
- 'form.targetId'(val) {
- this.form.partnerContactId = null
- this.form.partnerContactName = null
- },
- },
- methods: {
- selectLable(type) {
- if (type) {
- const findItem = this.checkTypeColumns.find((item) => item.key == type)
- return findItem.value
- }
- },
- // 选择打卡类型
- pickCheckType(e) {
- this.form.punchType = e.value[0].key
- this.form.punchVal = e.value[0].value
- this.showCheckType = false
- },
- // 经销商
- closeDealer(dealer) {
- if (dealer) {
- this.form.targetId = dealer.id
- this.form.targetName = dealer.name
- }
- },
- // 关闭选择客户
- closeCust(user) {
- if (user) {
- this.form.targetId = user.id
- this.form.targetName = user.name
- }
- },
- closePartners(partners) {
- if (partners) {
- this.form.targetId = partners.id
- this.form.targetName = partners.name
- }
- },
- closePartnersConcat(concat) {
- if (concat) {
- this.form.partnerContactId = concat.id
- this.form.partnerContactName = concat.name
- }
- },
- openSelectUser() {
- if (this.form.punchType == '20') {
- this.$refs.cust.open()
- } else if (this.form.punchType == '30' || this.form.punchType == '40') {
- this.$refs.dealer.open()
- } else if (this.form.punchType == '50') {
- this.$refs.partners.open()
- }
- },
- openPartnersConcat() {
- this.$refs.partnersConcat.open(this.form.partnerContactId)
- },
- getLocation() {
- this.show = true
- const _this = this
- uni.getLocation({
- type: 'wgs84',
- success: function (res) {
- const latitude = res.latitude.toString()
- const longitude = res.longitude.toString()
- uni.request({
- header: {
- 'Content-Type': 'application/text',
- },
- url:
- process.uniEnv.VUE_APP_PROTOCOL +
- 'apis.map.qq.com/ws/geocoder/v1/?location=' +
- latitude +
- ',' +
- longitude +
- '&key=6REBZ-BRN6J-BMAFY-FIRI3-SMK43-G3FXU',
- success(re) {
- if (re.statusCode === 200) {
- _this.address = re.data.result.address
- _this.form.punchLat = latitude
- _this.form.punchLng = longitude
- _this.form.punchLocation = re.data.result.address
- _this.show = false
- } else {
- _this.address = '点击重试'
- this.$refs.uToast.show({
- type: 'error',
- message: '定位失败,请重试',
- })
- }
- },
- fail: (err) => (_this.show = false),
- })
- },
- fail: (err) => (_this.show = false),
- })
- },
- async checkIn() {
- const [fail, resp] = await to(this.$refs.form.validate())
- if (fail && fail.length > 0) {
- this.$refs.uNotify.show({
- top: this.height + this.paddingTop + 10,
- type: 'warning',
- message: fail[0].message,
- duration: 1000 * 3,
- })
- return
- }
- if (!this.form.punchLat || !this.form.punchLng) {
- this.address = '点击重试'
- return this.$refs.uToast.show({
- type: 'error',
- message: '定位失败,请重试',
- })
- }
- const [err, res] = await uni.chooseImage({
- count: 1, //默认9
- sizeType: ['original'], //可以指定是原图还是压缩图,默认二者都有
- sourceType: ['camera'],
- })
- if (err) return
- this.select(res)
- res.tempFiles[0].name = new Date().getTime() + ''
- res.tempFiles[0].type = ''
- },
- // // 选择上传触发函数
- select(e) {
- let url = process.uniEnv.VUE_APP_UPLOAD_WEED
- uni.request({
- url, //仅为示例,并非真实接口地址。
- success: (res) => {
- this.uploadFiles(e, res.data)
- },
- })
- },
- // 上传函数
- async uploadFiles(e, res) {
- let action = process.uniEnv.VUE_APP_PROTOCOL + res.publicUrl + '/' + res.fid
- uni.uploadFile({
- url: action,
- filePath: e.tempFilePaths[0],
- name: 'file',
- formData: {
- file: e.tempFiles[0],
- },
- success: (res) => {
- this.form.punchImg = action
- api.checkIn(this.form).then((res) => {
- this.shwoSuccess = true
- // this.$refs.uToast.show({
- // type: 'success',
- // message: '打卡成功',
- // })
- })
- },
- fail: () => {
- console.log('err')
- },
- })
- },
- showCheckList() {
- if (!this.showList) {
- this.queryForm.pageNum = 1
- this.checkList = []
- this.loadCheckList()
- }
- this.showList = !this.showList
- },
- async loadCheckList() {
- this.loadStatus = 'loading'
- const [err, res] = await to(api.getCheckList(this.queryForm))
- if (err) {
- this.loadStatus = 'nomore'
- return
- }
- if (res && res.code == 200) {
- this.checkList = [...this.checkList, ...(res.data.list || [])]
- // this.checkList = res.data.list
- this.total = res.data.total
- this.loadStatus = this.checkList.length == this.total ? 'nomore' : 'loadmore'
- } else {
- this.loadStatus = 'nomore'
- }
- },
- scrolltolower() {
- if (this.checkList.length < this.total && this.loadStatus != 'loading') {
- this.queryForm.pageNum++
- this.$u.throttle(this.loadCheckList(), 2000, false)
- }
- },
- goBack() {
- uni.navigateBack({
- //关闭当前页面,返回上一页面或多级页面。
- delta: 1,
- })
- },
- getNowTime() {
- let now = new Date()
- let year = now.getFullYear() //获取完整的年份(4位,1970-????)
- let month = now.getMonth() + 1 //获取当前月份(0-11,0代表1月)
- let today = now.getDate() //获取当前日(1-31)
- let hour = now.getHours() //获取当前小时数(0-23)
- let minute = now.getMinutes() //获取当前分钟数(0-59)
- let nowTime = ''
- nowTime =
- year +
- '-' +
- this.fillZero(month) +
- '-' +
- this.fillZero(today) +
- ' ' +
- this.fillZero(hour) +
- ':' +
- this.fillZero(minute)
- return nowTime
- },
- fillZero(str) {
- var realNum
- if (str < 10) {
- realNum = '0' + str
- } else {
- realNum = str
- }
- return realNum
- },
- },
- }
- </script>
- <style lang="scss" scoped>
- /deep/ .uni-file-picker {
- display: none;
- }
- .home {
- padding-top: 188rpx;
- height: 100%;
- .nav {
- position: absolute;
- left: 0;
- top: 0;
- width: 100%;
- height: 284rpx;
- background: #3e7ef8;
- .title {
- position: relative;
- text-align: center;
- font-size: 32rpx;
- font-weight: bold;
- color: #ffffff;
- .back {
- position: absolute;
- top: 0;
- bottom: 0;
- margin: auto;
- left: 70rpx;
- display: flex;
- }
- }
- }
- .main {
- display: flex;
- flex-direction: column;
- position: absolute;
- width: 100%;
- height: calc(100vh - 188rpx);
- background: #ffffff;
- box-shadow: 0 6rpx 19rpx 2rpx rgba(0, 45, 132, 0.15);
- border-radius: 31rpx 31rpx 0 0;
- padding: 0 32rpx;
- overflow: hidden;
- padding-bottom: 64rpx;
- .main-header {
- padding: 20rpx 40rpx;
- display: flex;
- justify-content: space-between;
- .user-info {
- display: flex;
- .user-img {
- width: 116rpx;
- height: 116rpx;
- border-radius: 50%;
- margin-right: 32rpx;
- }
- .info {
- height: 116rpx;
- margin-right: 32rpx;
- }
- }
- .more {
- display: flex;
- flex-direction: column;
- align-items: center;
- }
- }
- .main-container {
- flex: 1;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- .btn {
- width: 300rpx;
- height: 300rpx;
- border-radius: 50%;
- background: linear-gradient(70deg, #3e7ef8, #1d66dc);
- display: flex;
- justify-content: center;
- align-items: center;
- color: #fff;
- font-size: 48rpx;
- font-weight: bold;
- box-shadow: 0 6rpx 19rpx 2rpx rgba(29, 102, 220, 0.2);
- margin-bottom: 40rpx;
- }
- .location {
- display: flex;
- height: 32rpx;
- line-height: 32rpx;
- }
- }
- }
- .tips-wrap {
- width: 100%;
- height: 500px;
- position: relative;
- .tips-content {
- position: absolute;
- width: 100%;
- height: 100%;
- background: rgba(0, 0, 0, 0.6);
- top: 0;
- left: 0;
- padding: 40px 20px 20px;
- display: flex;
- align-items: center;
- flex-direction: column;
- .success-icon-wrap {
- background: #fff;
- width: 45px;
- height: 45px;
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .tit {
- font-size: 24px;
- color: #67c23a;
- margin: 20px 0;
- text-align: center;
- }
- .confirm {
- margin-top: 10px;
- width: 100px;
- }
- .content {
- display: flex;
- flex-direction: column;
- align-items: center;
- color: #fff;
- font-weight: bold;
- .mb20 {
- margin-bottom: 20px;
- }
- }
- }
- }
- }
- </style>
|