ActivityQRCode.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <template>
  2. <div class="ActivityQRCode">
  3. <van-form
  4. ref="tabstoreVal"
  5. class="QRCodeActivity"
  6. :disabled="approvalStatus == '1' || approvalStatus == '2' || approvalStatus == null">
  7. <div class="activityItem">
  8. <span class="van-f-red">*</span>
  9. <van-field
  10. v-model="activityForm.summaryEventName"
  11. name="summaryEventName"
  12. label="活动名称"
  13. placeholder="请输入活动名称"
  14. :rules="[{ required: true }]" />
  15. </div>
  16. <div class="activityItem">
  17. <span class="van-f-red">*</span>
  18. <van-field
  19. readonly
  20. clickable
  21. name="summaryEventDate"
  22. :value="activityForm.summaryEventDate"
  23. label="活动日期"
  24. placeholder="请选择活动日期"
  25. @click="activityShowCalendarFun"
  26. :rules="[{ required: true }]" />
  27. </div>
  28. <div class="activityItem">
  29. <span class="van-f-red">*</span>
  30. <van-field
  31. readonly
  32. clickable
  33. name="qrStartTime"
  34. :value="activityForm.qrStartTime"
  35. label="生效开始日期"
  36. placeholder="请选择开始日期"
  37. @click="clickValidDateShow('start')"
  38. :rules="[{ required: true }]" />
  39. </div>
  40. <div class="activityItem">
  41. <span class="van-f-red">*</span>
  42. <van-field
  43. readonly
  44. clickable
  45. name="qrEndTime"
  46. :value="activityForm.qrEndTime"
  47. label="生效结束日期"
  48. placeholder="请选择结束日期"
  49. @click="clickValidDateShow('end')"
  50. :rules="[{ required: true }]" />
  51. </div>
  52. <div class="activityItem">
  53. <div class="van-cell QRCodeBtnBox">
  54. <van-button class="QRCodeBtn" color="#0057ba" @click="openQRCode">
  55. 签到二维码
  56. </van-button>
  57. <div class="tips">必须门店老板现场,使用企业微信扫码</div>
  58. </div>
  59. </div>
  60. <div class="activityItem">
  61. <div class="van-cell refreshBtnBox" style="padding: 5px 16px" @click="getQRChainList">
  62. <div style="font-size: 16px; margin-right: 10px">已签到成功</div>
  63. <div class="refresh">
  64. <van-icon
  65. style="font-weight: 600; margin-top: 1px"
  66. name="replay"
  67. size="20"
  68. color="#1989fa" />
  69. </div>
  70. </div>
  71. </div>
  72. <div class="activityItem">
  73. <div class="van-cell chainListBox">
  74. <div class="jxsContent">
  75. <div class="item" v-for="(val, index) in QRChainList">
  76. <el-popover
  77. placement="bottom"
  78. trigger="click"
  79. :content="val.storeName + '(' + val.storeCode + ')'">
  80. <template slot="reference">
  81. <div class="selectItem">{{ val.storeName }} &nbsp; ({{ val.storeCode }})</div>
  82. </template>
  83. </el-popover>
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. </van-form>
  89. <!-- 活动日期 -->
  90. <van-calendar v-model="activityShowCalendar" @confirm="activityOnConfirm" />
  91. <!-- 生效日期 -->
  92. <van-popup v-model="validDateShow" capture position="bottom">
  93. <van-datetime-picker
  94. v-model="validDate"
  95. :title="activate.title"
  96. :min-date="activate.minDate"
  97. :max-date="activate.maxDate"
  98. type="datetime"
  99. @cancel="validDateShow = false"
  100. @confirm="onValidDateConfirm" />
  101. </van-popup>
  102. <!-- 二维码 -->
  103. <div class="QRCodeBox" v-if="QRCodeBox">
  104. <div class="centerBox">
  105. <div class="title">{{ activityForm.summaryEventName }}</div>
  106. <div class="activityDate">{{ activityForm.summaryEventDate }}</div>
  107. <img class="QRCodeUrl" :src="this.QRCodeUrl" />
  108. <div class="validTimeBox">
  109. <div class="text">二维码有效期</div>
  110. <div class="validTime">
  111. {{ activityForm.qrStartTime }}
  112. ~
  113. {{ activityForm.qrEndTime }}
  114. </div>
  115. </div>
  116. <div class="close" @click="QRCodeBox = false">关闭</div>
  117. </div>
  118. </div>
  119. </div>
  120. </template>
  121. <script>
  122. import { getSummaryQrCheckList, getSummaryQrCodeUUID } from '@/api/index';
  123. export default {
  124. props: {
  125. ActivityQRCodeData: {
  126. type: Object,
  127. },
  128. qrUuid: {
  129. type: String,
  130. },
  131. approvalStatus: {
  132. type: String,
  133. },
  134. userSummaryId: {
  135. type: [String, Number],
  136. },
  137. },
  138. data() {
  139. return {
  140. // 活动数据
  141. activityForm: {
  142. summaryEventName: '',
  143. summaryEventDate: '',
  144. qrStartTime: '',
  145. qrEndTime: '',
  146. },
  147. activityShowCalendar: false,
  148. validDateShow: false,
  149. QRCodeUrl: '',
  150. QRCodeBox: false,
  151. activate: {
  152. type: '',
  153. title: '',
  154. minDate: new Date(2020, 0, 1),
  155. maxDate: new Date(2025, 10, 1),
  156. },
  157. validDate: new Date(),
  158. QRChainList: [],
  159. qrUuids: null,
  160. };
  161. },
  162. created() {
  163. if (this.ActivityQRCodeData) this.activityForm = this.ActivityQRCodeData;
  164. if (this.qrUuid) {
  165. this.qrUuids = this.qrUuid;
  166. this.getQRChainList();
  167. }
  168. },
  169. methods: {
  170. activityOnConfirm(date) {
  171. this.activityForm.summaryEventDate = this.formatDate(date);
  172. this.activityShowCalendar = false;
  173. },
  174. // 打开二维码
  175. openQRCode(value) {
  176. this.toastLoading(0, '加载中...', true);
  177. // approvalStatus//1-待审批 2-审批通过 不支持修改,直接查看二维码
  178. if (
  179. this.approvalStatus == '1' ||
  180. this.approvalStatus == '2' ||
  181. this.approvalStatus == '3' ||
  182. this.approvalStatus == null
  183. ) {
  184. getSummaryQrCodeUUID({ qrUuid: this.qrUuid, userSummaryId: this.userSummaryId }).then(
  185. (res) => {
  186. this.toastLoading().clear();
  187. this.QRCodeUrl = res.data.base64Png;
  188. this.QRCodeBox = true;
  189. }
  190. );
  191. } else {
  192. this.$refs.tabstoreVal
  193. .validate()
  194. .then(() => {
  195. // 验证通过
  196. this.$emit('onSubmit', (res) => {
  197. this.toastLoading().clear();
  198. this.QRCodeBox = true;
  199. this.QRCodeUrl = res.data.base64Png;
  200. this.qrUuids = res.data.qrUuid;
  201. });
  202. })
  203. .catch((errors) => {
  204. this.toastLoading().clear();
  205. //验证失败
  206. window.scrollTo(0, 0);
  207. });
  208. }
  209. },
  210. activityShowCalendarFun() {
  211. if (this.approvalStatus == '1' || this.approvalStatus == '2' || this.approvalStatus == null)
  212. return;
  213. this.activityShowCalendar = true;
  214. },
  215. clickValidDateShow(type) {
  216. if (this.approvalStatus == '1' || this.approvalStatus == '2' || this.approvalStatus == null)
  217. return;
  218. if (type == 'start') {
  219. this.activate = {
  220. type: type,
  221. title: '请选择开始日期',
  222. minDate: new Date(2025, 9, 1),
  223. maxDate: new Date(2026, 9, 1),
  224. };
  225. this.validDate = new Date(2025, 9, 1);
  226. } else {
  227. this.activate = {
  228. type: type,
  229. title: '请选择结束日期',
  230. minDate: this.activityForm.qrStartTime
  231. ? new Date(this.activityForm.qrStartTime)
  232. : new Date(),
  233. maxDate: new Date(2026, 9, 1),
  234. };
  235. this.validDate = this.activityForm.qrEndTime
  236. ? new Date(this.activityForm.qrEndTime)
  237. : new Date();
  238. }
  239. this.validDateShow = true;
  240. },
  241. onValidDateConfirm(date) {
  242. let time = this.parseTime(new Date(date), '{y}-{m}-{d} {h}:{i}:{s}') + '';
  243. if (this.activate.type == 'start') {
  244. this.activityForm.qrStartTime = time;
  245. if (
  246. new Date(this.activityForm.qrStartTime).getTime() >
  247. new Date(this.activityForm.qrEndTime).getTime()
  248. ) {
  249. this.activityForm.qrEndTime = null;
  250. }
  251. } else {
  252. this.activityForm.qrEndTime = time;
  253. }
  254. this.validDateShow = false;
  255. },
  256. formatDate(date) {
  257. var Month = date.getMonth() + 1;
  258. var Day = date.getDate();
  259. if (Month < 10) {
  260. Month = '0' + Month;
  261. }
  262. if (Day < 10) {
  263. Day = '0' + Day;
  264. }
  265. return `${date.getFullYear()}-${Month}-${Day}`;
  266. },
  267. getQRChainList() {
  268. if (!this.qrUuids) return;
  269. this.QRChainList = [];
  270. this.toastLoading(0, '加载中...', true);
  271. getSummaryQrCheckList({ qrUuid: this.qrUuids }).then((res) => {
  272. this.toastLoading().clear();
  273. if (res.code == 200) {
  274. this.QRChainList = res.data;
  275. }
  276. });
  277. },
  278. },
  279. };
  280. </script>
  281. <style scoped lang="scss">
  282. .ActivityQRCode {
  283. .QRCodeActivity {
  284. background-color: white;
  285. margin-bottom: 10px;
  286. .activityItem {
  287. display: flex;
  288. .van-f-red {
  289. position: relative;
  290. left: 16px;
  291. top: 10px;
  292. z-index: 1;
  293. }
  294. .QRCodeBtnBox {
  295. justify-content: space-between;
  296. align-items: end;
  297. .QRCodeBtn {
  298. width: auto;
  299. border-radius: 10px;
  300. }
  301. .tips {
  302. font-size: 11px;
  303. }
  304. .van-button--normal {
  305. padding: 0 8px;
  306. }
  307. }
  308. .jxsContent {
  309. margin-bottom: 10px;
  310. .item {
  311. padding: 5px;
  312. background: #e9e9e9;
  313. margin: 5px 0;
  314. .el-popover__reference-wrapper {
  315. display: flex;
  316. justify-content: space-between;
  317. align-items: center;
  318. }
  319. .selectItem {
  320. flex: 1;
  321. white-space: nowrap;
  322. overflow: hidden;
  323. text-overflow: ellipsis;
  324. font-size: 14px;
  325. }
  326. }
  327. }
  328. }
  329. }
  330. .QRCodeBox {
  331. position: fixed;
  332. width: 100%;
  333. height: 100%;
  334. z-index: 9999999999;
  335. top: 0;
  336. left: 0;
  337. right: 0;
  338. bottom: 0;
  339. background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
  340. display: flex;
  341. align-items: center;
  342. justify-content: center;
  343. .centerBox {
  344. width: 90%;
  345. // height: 86%;
  346. background: rgba(255, 255, 255, 0.1);
  347. backdrop-filter: blur(10px);
  348. border-radius: 20px;
  349. padding: 10px 20px;
  350. box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  351. text-align: center;
  352. color: #fff;
  353. font-size: 18px;
  354. display: flex;
  355. flex-direction: column;
  356. align-items: center;
  357. .title {
  358. font-size: 24px;
  359. font-weight: 600;
  360. margin-bottom: 10px;
  361. }
  362. .activityDate {
  363. // font-size: 20px;
  364. margin: 10px 0;
  365. }
  366. .QRCodeUrl {
  367. width: 100%;
  368. margin: 10px 0;
  369. }
  370. .validTimeBox {
  371. margin-top: 10px;
  372. .validTime {
  373. margin: 20px 0;
  374. font-size: 14px;
  375. }
  376. }
  377. .close {
  378. width: 40%;
  379. padding: 10px 15px;
  380. background: rgba(255, 255, 255, 0.2);
  381. border-radius: 12px;
  382. }
  383. }
  384. }
  385. }
  386. </style>