| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387 |
- <template>
- <div class="ActivityQRCode">
- <van-form
- ref="tabstoreVal"
- class="QRCodeActivity"
- :disabled="approvalStatus == '1' || approvalStatus == '2' || approvalStatus == null">
- <div class="activityItem">
- <span class="van-f-red">*</span>
- <van-field
- v-model="activityForm.summaryEventName"
- name="summaryEventName"
- label="活动名称"
- placeholder="请输入活动名称"
- :rules="[{ required: true }]" />
- </div>
- <div class="activityItem">
- <span class="van-f-red">*</span>
- <van-field
- readonly
- clickable
- name="summaryEventDate"
- :value="activityForm.summaryEventDate"
- label="活动日期"
- placeholder="请选择活动日期"
- @click="activityShowCalendarFun"
- :rules="[{ required: true }]" />
- </div>
- <div class="activityItem">
- <span class="van-f-red">*</span>
- <van-field
- readonly
- clickable
- name="qrStartTime"
- :value="activityForm.qrStartTime"
- label="生效开始日期"
- placeholder="请选择开始日期"
- @click="clickValidDateShow('start')"
- :rules="[{ required: true }]" />
- </div>
- <div class="activityItem">
- <span class="van-f-red">*</span>
- <van-field
- readonly
- clickable
- name="qrEndTime"
- :value="activityForm.qrEndTime"
- label="生效结束日期"
- placeholder="请选择结束日期"
- @click="clickValidDateShow('end')"
- :rules="[{ required: true }]" />
- </div>
- <div class="activityItem">
- <div class="van-cell QRCodeBtnBox">
- <van-button class="QRCodeBtn" color="#0057ba" @click="openQRCode">
- 签到二维码
- </van-button>
- <div class="tips">必须门店老板现场,使用企业微信扫码</div>
- </div>
- </div>
- <div class="activityItem">
- <div class="van-cell refreshBtnBox" style="padding: 5px 16px" @click="getQRChainList">
- <div style="font-size: 16px; margin-right: 10px">已签到成功</div>
- <div class="refresh">
- <van-icon
- style="font-weight: 600; margin-top: 1px"
- name="replay"
- size="20"
- color="#1989fa" />
- </div>
- </div>
- </div>
- <div class="activityItem">
- <div class="van-cell chainListBox">
- <div class="jxsContent">
- <div class="item" v-for="(val, index) in QRChainList">
- <el-popover
- placement="bottom"
- trigger="click"
- :content="val.storeName + '(' + val.storeCode + ')'">
- <template slot="reference">
- <div class="selectItem">{{ val.storeName }} ({{ val.storeCode }})</div>
- </template>
- </el-popover>
- </div>
- </div>
- </div>
- </div>
- </van-form>
- <!-- 活动日期 -->
- <van-calendar v-model="activityShowCalendar" @confirm="activityOnConfirm" />
- <!-- 生效日期 -->
- <van-popup v-model="validDateShow" capture position="bottom">
- <van-datetime-picker
- v-model="validDate"
- :title="activate.title"
- :min-date="activate.minDate"
- :max-date="activate.maxDate"
- type="datetime"
- @cancel="validDateShow = false"
- @confirm="onValidDateConfirm" />
- </van-popup>
- <!-- 二维码 -->
- <div class="QRCodeBox" v-if="QRCodeBox">
- <div class="centerBox">
- <div class="title">{{ activityForm.summaryEventName }}</div>
- <div class="activityDate">{{ activityForm.summaryEventDate }}</div>
- <img class="QRCodeUrl" :src="this.QRCodeUrl" />
- <div class="validTimeBox">
- <div class="text">二维码有效期</div>
- <div class="validTime">
- {{ activityForm.qrStartTime }}
- ~
- {{ activityForm.qrEndTime }}
- </div>
- </div>
- <div class="close" @click="QRCodeBox = false">关闭</div>
- </div>
- </div>
- </div>
- </template>
- <script>
- import { getSummaryQrCheckList, getSummaryQrCodeUUID } from '@/api/index';
- export default {
- props: {
- ActivityQRCodeData: {
- type: Object,
- },
- qrUuid: {
- type: String,
- },
- approvalStatus: {
- type: String,
- },
- userSummaryId: {
- type: [String, Number],
- },
- },
- data() {
- return {
- // 活动数据
- activityForm: {
- summaryEventName: '',
- summaryEventDate: '',
- qrStartTime: '',
- qrEndTime: '',
- },
- activityShowCalendar: false,
- validDateShow: false,
- QRCodeUrl: '',
- QRCodeBox: false,
- activate: {
- type: '',
- title: '',
- minDate: new Date(2020, 0, 1),
- maxDate: new Date(2025, 10, 1),
- },
- validDate: new Date(),
- QRChainList: [],
- qrUuids: null,
- };
- },
- created() {
- if (this.ActivityQRCodeData) this.activityForm = this.ActivityQRCodeData;
- if (this.qrUuid) {
- this.qrUuids = this.qrUuid;
- this.getQRChainList();
- }
- },
- methods: {
- activityOnConfirm(date) {
- this.activityForm.summaryEventDate = this.formatDate(date);
- this.activityShowCalendar = false;
- },
- // 打开二维码
- openQRCode(value) {
- this.toastLoading(0, '加载中...', true);
- // approvalStatus//1-待审批 2-审批通过 不支持修改,直接查看二维码
- if (
- this.approvalStatus == '1' ||
- this.approvalStatus == '2' ||
- this.approvalStatus == '3' ||
- this.approvalStatus == null
- ) {
- getSummaryQrCodeUUID({ qrUuid: this.qrUuid, userSummaryId: this.userSummaryId }).then(
- (res) => {
- this.toastLoading().clear();
- this.QRCodeUrl = res.data.base64Png;
- this.QRCodeBox = true;
- }
- );
- } else {
- this.$refs.tabstoreVal
- .validate()
- .then(() => {
- // 验证通过
- this.$emit('onSubmit', (res) => {
- this.toastLoading().clear();
- this.QRCodeBox = true;
- this.QRCodeUrl = res.data.base64Png;
- this.qrUuids = res.data.qrUuid;
- });
- })
- .catch((errors) => {
- this.toastLoading().clear();
- //验证失败
- window.scrollTo(0, 0);
- });
- }
- },
- activityShowCalendarFun() {
- if (this.approvalStatus == '1' || this.approvalStatus == '2' || this.approvalStatus == null)
- return;
- this.activityShowCalendar = true;
- },
- clickValidDateShow(type) {
- if (this.approvalStatus == '1' || this.approvalStatus == '2' || this.approvalStatus == null)
- return;
- if (type == 'start') {
- this.activate = {
- type: type,
- title: '请选择开始日期',
- minDate: new Date(2025, 9, 1),
- maxDate: new Date(2026, 9, 1),
- };
- this.validDate = new Date(2025, 9, 1);
- } else {
- this.activate = {
- type: type,
- title: '请选择结束日期',
- minDate: this.activityForm.qrStartTime
- ? new Date(this.activityForm.qrStartTime)
- : new Date(),
- maxDate: new Date(2026, 9, 1),
- };
- this.validDate = this.activityForm.qrEndTime
- ? new Date(this.activityForm.qrEndTime)
- : new Date();
- }
- this.validDateShow = true;
- },
- onValidDateConfirm(date) {
- let time = this.parseTime(new Date(date), '{y}-{m}-{d} {h}:{i}:{s}') + '';
- if (this.activate.type == 'start') {
- this.activityForm.qrStartTime = time;
- if (
- new Date(this.activityForm.qrStartTime).getTime() >
- new Date(this.activityForm.qrEndTime).getTime()
- ) {
- this.activityForm.qrEndTime = null;
- }
- } else {
- this.activityForm.qrEndTime = time;
- }
- this.validDateShow = false;
- },
- formatDate(date) {
- var Month = date.getMonth() + 1;
- var Day = date.getDate();
- if (Month < 10) {
- Month = '0' + Month;
- }
- if (Day < 10) {
- Day = '0' + Day;
- }
- return `${date.getFullYear()}-${Month}-${Day}`;
- },
- getQRChainList() {
- if (!this.qrUuids) return;
- this.QRChainList = [];
- this.toastLoading(0, '加载中...', true);
- getSummaryQrCheckList({ qrUuid: this.qrUuids }).then((res) => {
- this.toastLoading().clear();
- if (res.code == 200) {
- this.QRChainList = res.data;
- }
- });
- },
- },
- };
- </script>
- <style scoped lang="scss">
- .ActivityQRCode {
- .QRCodeActivity {
- background-color: white;
- margin-bottom: 10px;
- .activityItem {
- display: flex;
- .van-f-red {
- position: relative;
- left: 16px;
- top: 10px;
- z-index: 1;
- }
- .QRCodeBtnBox {
- justify-content: space-between;
- align-items: end;
- .QRCodeBtn {
- width: auto;
- border-radius: 10px;
- }
- .tips {
- font-size: 11px;
- }
- .van-button--normal {
- padding: 0 8px;
- }
- }
- .jxsContent {
- margin-bottom: 10px;
- .item {
- padding: 5px;
- background: #e9e9e9;
- margin: 5px 0;
- .el-popover__reference-wrapper {
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
- .selectItem {
- flex: 1;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- font-size: 14px;
- }
- }
- }
- }
- }
- .QRCodeBox {
- position: fixed;
- width: 100%;
- height: 100%;
- z-index: 9999999999;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
- display: flex;
- align-items: center;
- justify-content: center;
- .centerBox {
- width: 90%;
- // height: 86%;
- background: rgba(255, 255, 255, 0.1);
- backdrop-filter: blur(10px);
- border-radius: 20px;
- padding: 10px 20px;
- box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
- text-align: center;
- color: #fff;
- font-size: 18px;
- display: flex;
- flex-direction: column;
- align-items: center;
- .title {
- font-size: 24px;
- font-weight: 600;
- margin-bottom: 10px;
- }
- .activityDate {
- // font-size: 20px;
- margin: 10px 0;
- }
- .QRCodeUrl {
- width: 100%;
- margin: 10px 0;
- }
- .validTimeBox {
- margin-top: 10px;
- .validTime {
- margin: 20px 0;
- font-size: 14px;
- }
- }
- .close {
- width: 40%;
- padding: 10px 15px;
- background: rgba(255, 255, 255, 0.2);
- border-radius: 12px;
- }
- }
- }
- }
- </style>
|