123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>活动</title>
- <meta name="viewport"
- content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
- <!--引入 element-ui 的样式,-->
- <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
- <!-- 必须先引入vue, 后使用element-ui -->
- <script src="./js/vue.js"></script>
- <!-- 引入element 的组件库-->
- <script src="https://unpkg.com/element-ui/lib/index.js"></script>
- <script src="https://unpkg.com/vconsole/dist/vconsole.min.js"></script>
- <script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
- <!-- <script>
- var vConsole = new window.VConsole();
- </script> -->
- </head>
- <style>
- body {
- margin: 0;
- padding: 0;
- }
- #box {
- width: 100vw;
- height: 100vh;
- box-sizing: border-box;
- }
- .lotteryPage {
- width: 100%;
- height: 620px;
- background: url('./img/lottery-bg.png');
- background-size: 100% 620px;
- background-repeat: no-repeat;
- position: relative;
- }
- .prize_content {
- padding: 267px 61px 0 60px;
- display: flex;
- flex-wrap: wrap;
- justify-content: center;
- gap: 10px;
- }
- .prize_item {
- width: 78px;
- height: 78px;
- background: url('./img/prize-bg.png');
- background-size: 78px 78px;
- background-repeat: no-repeat;
- display: flex;
- justify-content: center;
- align-items: center;
- flex-direction: column;
- font-weight: 400;
- font-size: 10px;
- color: #CC745A;
- box-sizing: border-box;
- }
- .prize_img {
- width: 48px;
- height: 48px;
- padding-bottom: 3px;
- }
- .lottery_btn {
- position: absolute;
- bottom: -14px;
- display: flex;
- flex-direction: column;
- align-items: center;
- width: 100%;
- }
- .btn_img {
- width: 290px;
- }
- .lottery_tip {
- text-align: center;
- font-size: 14px;
- color: #FFFFFF;
- font-weight: 600;
- line-height: 14px;
- }
- .rule {
- width: 100%;
- height: 509px;
- background: linear-gradient(180deg, #FF6C52 0%, #FFBA9B 100%);
- margin-top: -50px;
- padding: 65px 15px 40px;
- box-sizing: border-box;
- }
- .rule_body {
- height: 404px;
- background: #FEE8D0;
- border-radius: 20px;
- padding: 20px 15px;
- box-sizing: border-box;
- }
- .tabs {
- display: flex;
- justify-content: space-around;
- align-items: center;
- padding: 0 2px;
- margin: 0 auto;
- width: 255px;
- height: 34px;
- background: rgba(255, 125, 97, 0.2);
- border-radius: 17px 17px 17px 17px;
- }
- .tab_link {
- border: none;
- outline: none;
- cursor: pointer;
- transition: 0.3s;
- color: #FF765B;
- background: unset;
- width: 125px;
- height: 30px;
- border-radius: 17px
- }
- .tab_link:active {
- background: rgba(255, 125, 97, 0.2);
- }
- .tab_link.active {
- background: #FFFFFF;
- }
- .tab_content {
- p {
- font-weight: 400;
- font-size: 14px;
- color: #CB4E35;
- margin-top: 20px;
- }
- }
- .record_list {
- overflow-y: auto;
- height: 300px;
- margin-top: 18px;
- }
- .record_item {
- width: 315px;
- height: 72px;
- background: #FEDFC9;
- border-radius: 10px;
- padding: 9px 10px 8px;
- display: flex;
- align-items: center;
- margin: 0 auto 10px;
- box-sizing: border-box;
- }
- .record_img {
- width: 55px;
- height: 55px;
- border-radius: 10px;
- margin-right: 8px;
- }
- .get_btn {
- width: 72px;
- height: 30px;
- background: #FF4646;
- border-radius: 17px;
- font-size: 14px;
- color: #FFFFFF;
- margin-left: 30px;
- padding: 0;
- }
- .prize_name {
- font-size: 14px;
- font-weight: 500;
- color: #FF4646;
- }
- .prize_time {
- font-size: 12px;
- color: #FF6767;
- }
- .el-dialog {
- width: 335px;
- border-radius: 20px;
- }
- .el-dialog__header {
- text-align: center;
- }
- .el-dialog__title {
- font-weight: 500;
- font-size: 16px;
- color: #222222;
- }
- .el-dialog__body {
- height: 260px;
- overflow-y: auto;
- }
- .prize_form .el-form-item{
- padding: 0;
- }
- .prize_form .el-form-item__label {
- line-height: 20px;
- }
- .prize_form .el-input {
- width: 295px;
- }
- .prize_form .el-input__inner {
- text-align: left;
- }
- .prize_form .el-input.is-active .el-input__inner,
- .prize_form .el-input__inner:focus {
- border: 1px solid #FF4646;
- }
- .prize_form .el-textarea.is-active .el-textarea__inner,
- .prize_form .el-textarea__inner:focus {
- border: 1px solid #FF4646;
- }
- .el-radio__input.is-checked .el-radio__inner {
- border-color: #FF4646;
- background: #FF4646;
- }
- .el-radio__input.is-checked+.el-radio__label {
- color: #FF4646;
- }
- .el-select .el-input.is-focus .el-input__inner {
- border-color: #FF4646;
- }
- .dialog-footer {
- text-align: center;
- }
- .dialog-footer button {
- width: 100%;
- height: 46px;
- background: #FF4646;
- border-radius: 20px;
- font-weight: 500;
- font-size: 16px;
- color: #FFFFFF;
- border: none;
- }
- .prize_dialog {
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- background-color: rgba(0, 0, 0, 0.5);
- /* 半透明黑色 */
- z-index: 1000;
- /* 确保遮罩层在顶部 */
- transition: opacity 0.5s ease;
- /* 可选:添加透明度过渡效果 */
- }
- .dialog-body {
- width: 100%;
- height: 100%;
- z-index: 1001;
- /* 确保遮罩层在顶部 */
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- }
- .dialog-tip {
- width: 100%;
- height: 100px;
- }
- .dialog-bg {
- width: 295px;
- height: 251px;
- position: relative;
- }
- .prize-msg {
- position: absolute;
- text-align: center;
- }
- .money-title {
- font-weight: 500;
- font-size: 16px;
- color: #FF4E4E;
- padding-top: 90px;
- padding-bottom: 10px;
- }
- .money-content {
- margin-bottom: 30px;
- height: 60px;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- .prize-money {
- font-weight: bold;
- font-size: 60px;
- color: #FF4E4E;
- }
- .prize-unit {
- font-weight: 500;
- font-size: 16px;
- color: #FF4E4E;
- padding-left: 10px;
- padding-top: 28px;
- }
- .dialog-btn {
- width: 235px;
- height: 52px;
- margin-bottom: 10px;
- }
- .money-tip {
- font-weight: 400;
- font-size: 12px;
- color: #999999;
- margin-bottom: 15px;
- }
- .goods-img {
- width: 100px;
- height: 100px;
- margin: 70px 0 10px;
- }
- .goods-name {
- font-weight: 500;
- font-size: 16px;
- color: #222222;
- margin-bottom: 20px;
- }
- .dialog-close {
- width: 30px;
- height: 30px;
- margin-top: 20px;
- }
- .actives {
- border: 2px solid #df2727;
- border-radius: 15px;
- }
- .event_notice {
- width: 30px;
- height: 84px;
- background: rgba(255, 255, 255, 0.5);
- border-radius: 15px 0px 0px 15px;
- border: 1px solid #FFFFFF;
- font-weight: 500;
- font-size: 14px;
- color: #FF4E4E;
- position: absolute;
- right: 0;
- top: 20%;
- writing-mode: vertical-rl;
- text-align: center;
- padding-right: 4px;
- }
- .qrcode {
- width: 100vw;
- height: 100vh;
- box-sizing: border-box;
- display: flex;
- align-items: center;
- justify-content: center;
- flex-direction: column;
- }
- .qrcode-msg {
- text-align: center;
- font-size: 18px;
- }
- </style>
- <body>
- <div id="box">
- <!-- 二维码 -->
- <div class="qrcode" v-if="qrCodeData.qrCode">
- <img class="qrcode-img" :src="qrCodeData.qrCode" />
- <div class="qrcode-msg">{{qrCodeData.msg}}</div>
- </div>
- <div v-if="h5Type == 19 || !h5Type">
- <div class="lotteryPage">
- <div class="event_notice" @click="handleRule">
- <span>活动须知</span>
- </div>
- <div class="prize_content">
- <div :class="['prize_item', { actives: isSpinning && index === currentIndex }]" v-for="(item, index) in prizesList" :key="index">
- <img class="prize_img" :src="item.img"></img>
- <div>{{item.name}}</div>
- </div>
- </div>
- <div class="lottery_btn">
- <img class="btn_img" src="./img/btn.png" @click="handleLottery"></img>
- <div class="lottery_tip">已抽奖{{useNum}}次,还剩{{remainNum}}次机会</div>
- </div>
- </div>
- <div class="rule">
- <div class="rule_body">
- <div class="tabs">
- <Button class="tab_link" :class="{ 'active': activeName === 'tab1' }" @click="changeTab('tab1')">活动信息</Button>
- <Button class="tab_link" :class="{ 'active': activeName === 'tab2' }" @click="changeTab('tab2')">抽奖记录</Button>
- </div>
- <div v-if="activeName === 'tab1'" class="tab_content record_list" v-html="activeMsg"></div>
- <div v-if="activeName === 'tab2'" class="record_list">
- <div class="record_item" v-for="(item, index) in lotteryRecords" :key="index">
- <img class="record_img" :src="item.img" mode="widthFix" />
- <div>
- <div class="prize_name">{{item.name}}</div>
- <div class="prize_time">{{timeFormat(item.raffleTime)}}</div>
- </div>
- <el-button :disabled="item.status == -1 || item.status == 1" class="get_btn" onclick="handleOpenForm(item.id)">{{item.status == 1 ? '已领取' : (item.status == -1 ? '审核中' : '领取')}}</el-button>
- </div>
- </div>
- </div>
- </div>
- </div>
- <!-- 奖励弹窗 -->
- <div class="prize_dialog" v-if="showPrizeDialog">
- <div class="dialog-body">
- <img class="dialog-tip" src="./img/dialog-tip.png" />
- <img class="dialog-bg" src="./img/dialog-bg.png" />
- <div class="prize-msg" v-if="prizeData.acceptType === 2">
- <div class="money-title">微信红包</div>
- <div class="money-content">
- <span class="prize-money">{{prizeData.money}}</span>
- <span class="prize-unit">元</span>
- </div>
- <img class="dialog-btn" src="./img/dialog-btn.png" @click="showPrizeDialog = false"/>
- <div class="money-tip">红包到账会有延迟情况,请以实际为准</div>
- </div>
- <div class="prize-msg" v-if="prizeData.acceptType === 0 || prizeData.acceptType === 1">
- <img class="goods-img" :src="prizeData.img" />
- <div class="goods-name">{{prizeData.name}}</div>
- <img class="dialog-btn" src="./img/dialog-btn.png" @click="showPrizeDialog = false" />
- </div>
- <img class="dialog-close" src="./img/dialog-close.png" @click="showPrizeDialog = false" />
- </div>
- </div>
- <!-- 活动须知弹框 -->
- <el-dialog
- title="活动须知"
- :visible.sync="showRuleDialog">
- <div>以下隐私协议是本产品对用户隐私保护的许诺,请您务必仔细阅读本协议,以了解我们关于管理您个人信息的情况。本隐私协议的全部条款属于本产品用户服务协议的重要部份之一。<br />
- 为了给您提供更准确、更有针对性的服务,本产品可能会以如下方式,使用您授权的个人信息。但本产品会以高度的勤勉义务对待这些信息,在未征得您许可的情况下,不会将这些信息对外公开或向第三方提供。<br />
- 请务必遵守《微信开放平台协议》、《微信公众平台协议》、《企业微信服务协议》、《企业微信隐私保护协议》、《微信商户号服务协议》、《微信外部链接内容管理规范》等微信相关管理规范,我们不承担因违反上述管理规范所导致的任何责任。<br />
- 一、您已经认真阅读参与的活动信息,自愿参加相关活动。您自愿并乐意将活动链接、海报、文案等信息转发分享到微信朋友圈、微信群、微信聊天等渠道,并不是因为诱导的情况下参与相关活动、分享相关活动。<br />
- 二、您自愿选择服务或提供信息的情况下收集您的个人信息(包括但不限于,微信昵称,微信头像,微信地址,微信关联手机号等),并将这些信息进行整合,以便向您提供更好的用户服务。<br />
- 三、保有您的使用记录在如下情况下,本产品会遵照您的意愿或法律的规定披露您的个人信息(包括但不限于,微信昵称,微信头像,微信地址,微信关联手机号等),由此引发的问题将由您个人承担: <br />
- 1)事先获得您的授权<br />
- 2)只有获取您的个人资料,才能提供您所要求的服务 <br />
- 3)根据有关的法律法规要求<br />
- 4)按照相关政府主管部门的要求 <br />
- 5)为维护本产品的合法权益<br />
- 6)您同意让第三方共享资料<br />
- 7)我们发现您违反了本产品的服务条款或使用规定 <br />
- 8)我们需要向代表我们提供产品或服务的公司提供资料 (除非我们另行通知您,否则这些公司无权使用您的身份识别资料)<br />
- 四、本《隐私协议》不适用于以下情况: <br />
- 1)通过我们的服务而接入的第三方服务(包括任何第三方网站)收集的信息。本政策仅适用于我们所收集的信息,并不适用于任何第三方提供的服务或第三方的信息使用规则,我们对任何第三方使用由您提供的信息不承担任何责任。<br />
- 2)通过在我们服务中进行广告服务的其他公司或机构所收集的信息。<br />
- </div>
- </el-dialog>
- <el-dialog title="收货地址" :visible.sync="showDialog">
- <el-form :model="form" class="prize_form">
- <el-form-item label="姓名:">
- <el-input v-model="form.name" autocomplete="off"></el-input>
- </el-form-item>
- <el-form-item label="微信号:">
- <el-input v-model="form.wxAccount" autocomplete="off"></el-input>
- </el-form-item>
- <el-form-item label="手机号:">
- <el-input v-model="form.phone" autocomplete="off"></el-input>
- </el-form-item>
- <el-form-item label="地区:">
- <el-cascader
- v-model="cityData"
- :options="transformedData"
- @change="handleChangeCity">
- </el-cascader>
- </el-form-item>
- <el-form-item label="详细地址:">
- <el-input v-model="form.address" autocomplete="off"></el-input>
- </el-form-item>
- <el-form-item label="备注:">
- <el-input v-model="form.remark" type="textarea" autocomplete="off"></el-input>
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button type="primary" @click="handleSave">确 定</el-button>
- </div>
- </el-dialog>
- <el-dialog title="请问您是否已购五菱/宝骏车型?" :visible.sync="showTipDialog" :show-close="false" :close-on-click-modal="false">
- <el-form :model="form" class="prize_form"label-position="top">
- <el-form-item label="姓名:">
- <el-radio-group v-model="radioYesNo">
- <el-radio :label="1">是</el-radio>
- <el-radio :label="0">否</el-radio>
- </el-radio-group>
- </el-form-item>
- <el-form-item label="已购车型:" v-if="radioYesNo === 1">
- <el-select v-model="carData" placeholder="请选择">
- <el-option
- v-for="item in allCarList"
- :key="item"
- :label="item"
- :value="item">
- </el-option>
- </el-select>
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button type="primary" @click="handleSaveCar">确 定</el-button>
- </div>
- </el-dialog>
- </div>
- <script>
- new Vue({
- el: '#box',
- data() {
- return {
- httpUrl: true,
- h5Type: null,
- qrCodeData: {
- qrCode: '',
- msg: '',
- },
- bId: null,
- shareTitle: '',
- shareDes: '',
- shareCover: '',
- prizesList: [],
- useNum: null,
- remainNum: null,
- activeMsg: '',
- lotteryRecords: [],
- activeName: 'tab1',
- showDialog: false,
- form: {
- name: '',
- wxAccount: '',
- phone: '',
- province: '',
- city: '',
- address: '',
- remark: '',
- recordId: null,
- },
- transformedData: [],
- cityData: '',
- showTipDialog: false,
- allCarList: [],
- radioYesNo: 1,
- carData: '',
- prizeData: {
- acceptType: null,
- name: '',
- img: '',
- money: '',
- id: null
- },
- showPrizeDialog: false,
- lotteryStatus: null,
- currentIndex: 0, // 当前活动的格子索引
- isSpinning: false,
- intervalId: null,
- showRuleDialog: false
- }
- },
- created() {
- if (this.httpUrl) {
- this.httpUrl = 'https://wlapi.wefanbot.com'
- } else {
- this.httpUrl = 'http://test.wefanbot.com:18993'
- }
- this.bId = this.getQueryParam('bId')
- this.h5Type = this.getQueryParam('h5Type')
- if (this.h5Type == 19 || !this.h5Type) {
- // if (this.getQueryParam('openId') || localStorage.getItem('openId')) {
- // if (!this.getQueryParam('externalUserid')) {
- // this.gerQwAuth(this.bId);
- // } else {
- // if (this.getQueryParam('externalUserid') === 'unknown') {
- // this.gerQwCode(this.bId);
- // } else {
- this.raffleInfo();
- this.raffleRecord()
- this.getCityLevel()
- this.getAllCar()
- this.getQyWxSign()
- // }
- // }
- // } else {
- // // 走授权操作
- // this.getAuth();
- // }
- } else if (this.h5Type == 20) {
- // 宝骏云海送祝福
- var currentQueryParams = window.location.search;
- window.location.replace('h5Type-20.html' + currentQueryParams)
- } else if (this.h5Type == 21) {
- // 活码
- var currentQueryParams = window.location.search;
- window.location.replace('live_code.html' + currentQueryParams)
- } else if (this.h5Type == 22) {
- // 红包兑换
- var currentQueryParams = window.location.search;
- window.location.replace('receiveMoney.html' + currentQueryParams)
- }
- },
- methods: {
- // 公众号授权,获取code
- getAuth () {
- // 获取url上的code
- let code = this.getQueryParam('code')
- if (code) {
- fetch(this.httpUrl + `/scrm/v1/mp-client/p/getInfoByh5Code?code=${code}&bId=${this.bId}`)
- .then(res => {
- return res.json()
- }).then(result => {
- let { data, code, msg } = result
- if (code === 1) {
- this.h5Type = data.h5Type
- localStorage.setItem('openId', data.openId)
- this.gerQwAuth(this.bId);
- }
- })
- } else {
- let redirect_uri = window.location.href
- // code 不存在,走微信网页授权逻辑
- let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appId=wx99ec0d0828a4d2d3&redirect_uri=${redirect_uri}&scope=snsapi_userinfo&state=STATE#wechat_redirect`
- window.location.replace(url)
- }
- },
- // 企微授权
- gerQwAuth (bId) {
- let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
- fetch(this.httpUrl + `/p/insuite/p/getOAUrl?openId=${openId}&bId=${bId}`)
- .then(res => {
- return res.json()
- }).then(result => {
- let { data, code, msg } = result
- if (code === 1) {
- window.location.replace(data)
- } else {
- this.$message({
- message: msg,
- type: 'warning'
- })
- }
- })
- },
- // 获取二维码
- gerQwCode (bId) {
- fetch(this.httpUrl + `/scrm/v1/wxcp-raffle/p/getUnknown?bId=${bId}`)
- .then(res => {
- return res.json()
- }).then(result => {
- let { data, code, msg } = result
- if (code === 1) {
- this.qrCodeData = data
- } else {
- this.$message({
- message: msg,
- type: 'warning'
- })
- }
- })
- },
- // 内容类型的分享页,获取企业微信的签名
- getQyWxSign () {
- let shareUrl = `${window.location.origin}?bId=${this.bId}&h5Type=${this.h5Type}`
- fetch(this.httpUrl + `/scrm/v1/ct-share/p/getSignature?url=${window.location.href}`)
- .then(res => {
- return res.json()
- }).then(result => {
- let { data, code, msg } = result
- if (code === 1) {
- wx.config({
- debug: false,
- appId: data.appId, // 必填,企业号的唯一标识,此处填写企业号corpid
- timestamp: data.timestamp, // 必填,生成签名的时间戳
- nonceStr: data.nonceStr, // 必填,生成签名的随机串
- signature: data.signature, // 必填,签名,见附录1
- jsApiList: ['updateAppMessageShareData', 'updateTimelineShareData'] // 必填,需要使用的JS接口列表
- })
- // 分享接口仅激活的成员数超过200人且已经认证的企业才可在微信上调用。
- wx.ready(() => {
- let shareData = {
- link: shareUrl,
- title: this.shareTitle, // 分享标题
- desc: this.shareDes, // 分享描述
- imgUrl: this.shareCover,
- }
- // 分享到朋友圈
- wx.updateAppMessageShareData(shareData)
- // 分享给朋友
- wx.updateTimelineShareData(shareData);
- // 配置失败的回调函数
- wx.error(function(res) {
- // 配置失败
- console.log('配置失败', res);
- })
- })
- } else {
- // this.$message({
- // message: msg,
- // type: 'warning'
- // })
- }
- })
- },
- // 获取抽奖信息
- raffleInfo () {
- fetch(this.httpUrl + `/scrm/v1/wxcp-raffle/p/raffleInfoByOpenId?openId=${this.getQueryParam('openId') || localStorage.getItem('openId')}&raffleId=${this.bId}`)
- .then(res => {
- return res.json()
- }).then(result => {
- let { data, code, msg } = result
- if (code === 1) {
- this.lotteryStatus = data.status
- this.prizesList = data.prizes
- this.useNum = data.useNum
- this.remainNum = data.raffleNum - data.useNum
- this.activeMsg = data.activityInfo
- this.shareTitle = data.name
- this.shareDes = data.description
- this.shareCover = data.cover
- if (data.preForm) {
- this.showTipDialog = true
- }
- }
- })
- },
- // 抽奖记录
- raffleRecord () {
- fetch(this.httpUrl + '/scrm/v1/wxcp-raffle/p/raffleRecord', {
- method: 'post',
- body: JSON.stringify({
- openId: this.getQueryParam('openId') || localStorage.getItem('openId'),
- raffleId: this.bId,
- page: 1,
- pageCount: 1000,
- }),
- headers: {
- 'Content-Type': 'application/json'
- }
- }).then(res => {
- return res.json()
- }).then(result => {
- let { data, code, msg } = result
- if (code === 1) {
- this.lotteryRecords = data.records
- }
- })
- },
- changeTab (tabName) {
- this.activeName = tabName
- },
- handleOpenForm (id) {
- this.form.recordId = id
- this.showDialog = true
- },
- handleSave () {
- if (!this.form.name) {
- this.$message({
- message: '请填写姓名',
- type: 'warning'
- })
- return
- }
- if (!this.form.phone) {
- this.$message({
- message: '请输入手机号',
- type: 'warning'
- })
- return
- }
- if (!this.form.province) {
- this.$message({
- message: '请选择城市',
- type: 'warning'
- })
- return
- }
- fetch(this.httpUrl + '/scrm/v1/wxcp-raffle/p/raffleForm', {
- method: 'post',
- body: JSON.stringify(this.form),
- headers: {
- 'Content-Type': 'application/json'
- }
- }).then(res => {
- return res.json()
- }).then(result => {
- let { data, code, msg } = result
- if (code === 1) {
- this.$message({
- message: '提交成功!',
- type: 'success'
- })
- this.showDialog = false
- this.raffleRecord()
- }
- })
- },
- handleSaveCar () {
- if (this.radioYesNo && !this.carData) {
- this.$message({
- message: '请选择已购车型',
- type: 'warning'
- })
- return
- }
- fetch(this.httpUrl + '/scrm/v1/wxcp-raffle/p/submitPreForm', {
- method: 'post',
- body: JSON.stringify({
- bid: this.bId,
- buyCar: this.radioYesNo,
- car: this.radioYesNo ? this.carData : '',
- mpOpenId: this.getQueryParam('openId') || this.localStorage.getItem('openId'),
- }),
- headers: {
- 'Content-Type': 'application/json'
- }
- }).then(res => {
- return res.json()
- }).then(result => {
- let { data, code, msg } = result
- if (code === 1) {
- this.$message({
- message: '提交成功!',
- type: 'success'
- })
- this.showTipDialog = false
- }
- })
- },
- // 获取城市数据
- getCityLevel () {
- fetch('https://wl-1306604067.cos.ap-guangzhou.myqcloud.com/production/ct/1000/1720161853377/pc-code.json')
- .then(res => {
- return res.json()
- }).then(result => {
- this.transformedData = this.transformData(result)
- })
- },
- // 获取全部车型
- getAllCar () {
- fetch(this.httpUrl + `/scrm/v1/wxcp-raffle/p/getCarList`)
- .then(res => {
- return res.json()
- }).then(result => {
- let { data, code, msg } = result
- if (code === 1) {
- this.allCarList = data
- }
- })
- },
- handleChangeCity (value) {
- this.form.province = value[0]
- this.form.city = value[1]
- },
- // 点击抽奖
- handleLottery () {
- if (!this.remainNum) {
- this.$message({
- message: '暂无抽奖次数',
- type: 'warning'
- })
- return
- }
- if (this.lotteryStatus === -1) {
- this.$message({
- message: '活动已结束',
- type: 'warning'
- })
- } else if (this.lotteryStatus === 0) {
- this.$message({
- message: '活动未开始',
- type: 'warning'
- })
- } else if (this.lotteryStatus === 1) {
- if (this.isSpinning) return
- this.isSpinning = true
- this.currentIndex = 0
- let externalUserid = this.getQueryParam('externalUserid')
- let openId = this.getQueryParam('openId') || localStorage.getItem('openId')
- fetch(this.httpUrl + `/scrm/v1/wxcp-raffle/p/lottery?externalUserid=${externalUserid}&openId=${openId}&raffleId=${this.bId}`)
- .then(res => {
- return res.json()
- }).then(result => {
- let { data, code, msg } = result
- if (code === 1) {
- this.stopLottery()
- this.prizeData = data
- this.showPrizeDialog = true
- this.raffleInfo();
- this.raffleRecord();
- } else {
- this.stopLottery()
- this.$message({
- message: msg,
- })
- }
- })
- // 开始转圈
- this.intervalId = setInterval(() => {
- this.currentIndex = (this.currentIndex + 1) % 9;
- }, 200); // 每 200 毫秒转一次
- }
- },
- // 停止抽奖
- stopLottery() {
- clearInterval(this.intervalId);
- this.isSpinning = false;
- this.currentIndex = null;
- },
- handleRule () {
- this.showRuleDialog = true
- },
- // 省市数据做转换
- transformData(data) {
- return data.map(item => {
- // 创建一个新对象,避免直接修改原始对象
- const newItem = { ...item };
-
- // 重命名 text 为 label
- if (newItem.text) {
- newItem.label = newItem.text;
- newItem.value = newItem.text;
- delete newItem.text;
- }
-
- // 如果存在 children 数组,则递归处理每个子项
- if (newItem.children && Array.isArray(newItem.children)) {
- newItem.children = this.transformData(newItem.children);
- }
-
- return newItem;
- })
- },
- // 截取url中的数据
- getQueryParam (paramName) {
- // 获取当前URL的查询字符串部分
- const queryString = window.location.search;
- // 创建一个URLSearchParams对象
- const urlParams = new URLSearchParams(queryString);
- // 返回指定参数的值,如果不存在则返回null
- return urlParams.get(paramName);
- },
- timeFormat (time, format = 'yyyy-MM-dd hh:mm:ss') {
- if (time === undefined || time === '' || time === null) {
- return '/'
- } else {
- const date = new Date(time)
- const o = {
- 'M+': date.getMonth() + 1,
- 'd+': date.getDate(),
- 'h+': date.getHours(),
- 'm+': date.getMinutes(),
- 's+': date.getSeconds(),
- 'q+': Math.floor((date.getMonth() + 3) / 3),
- 'S': date.getMilliseconds()
- }
- if (/(y+)/.test(format)) {
- format = format.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length))
- }
- for (let k in o) {
- if (new RegExp('(' + k + ')').test(format)) {
- format = format.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
- }
- }
- return format
- }
- },
- }
- })
- </script>
- </body>
- </html>
|