vue開發微信商城項目總結之五--vue實現九宮格抽獎

根據產品提出的需求,
須要作一個抽獎活動頁面前端

需求簡介

九宮格抽獎,中獎機率可配置,以九宮格轉盤的形式進行抽獎,獎品分爲三類,vue

  1. 實物類獎品,收貨人信息可編輯,默認爲登錄用戶,可生成訂單
  2. 福幣類獎品,直接發放,可在交易明細中查看
  3. 優惠劵類獎品,交易明細中查看

九宮格轉動以後,中獎以前,要進行降速處理,獲獎後能夠在右上角查看中獎記錄,
活動未開始不能抽獎,而且更換按鈕狀態git

示意圖

圖片描述

該項目脫離了Jquery,採用原生js和vue實現
項目地址在這裏github

後臺接口結構

{
  "bizCode": "000000",
  "bizMessage": "",
  "data": {
    "prizeDesc": "每人100次$utf8$一等獎華爲p10",
    "winners": [{
      "randomId": "11120fba76224eda8f819f0d0058606a",
      "level": 1,
      "name": "張三",
      "mobile": "153****91106",
      "commodityName": "華爲 P10 Plus 全網通 4G 手機 雙卡雙待-6G+128G-玫瑰金"
    }, {
      "randomId": "fd47133f9bb4453a86a659f81640d1ef",
      "level": 4,
      "name": "張四",
      "mobile": "189****01366",
      "commodityName": "15福幣"
    }, {
      "randomId": "e9ba39c8773b4edebf45e1e3c35f3fc1",
      "level": 2,
      "name": "張五",
      "mobile": "189****01366",
      "commodityName": "200優惠券"
    }, {
      "randomId": "88e3ecdabc354d7a8c0b56a822a6f5a5",
      "level": 3,
      "name": "張六",
      "mobile": "150****00451",
      "commodityName": "100優惠券"
    }, {
      "randomId": "784227fd523841afac3dee0e6a377113",
      "level": 8,
      "name": "李四",
      "mobile": "189****01366",
      "commodityName": "3福幣"
    }, {
      "randomId": "7a95ad0b9522442a8ca12859e41f1fb9",
      "level": 8,
      "name": "李五",
      "mobile": "151****73957",
      "commodityName": "3福幣"
    }, {
      "randomId": "0b92100d0a354ad3be334edf826c61e5",
      "level": 8,
      "name": "李六",
      "mobile": "151****73957",
      "commodityName": "3福幣"
    }, {
      "randomId": "4b0a012886cd473d962f5ad9b60ba7e6",
      "level": 8,
      "name": "李七",
      "mobile": "151****73957",
      "commodityName": "3福幣"
    }, {
      "randomId": "46e31a4dfd0d4cf889f1c0b8f9f04075",
      "level": 7,
      "name": "李八",
      "mobile": "136****49120",
      "commodityName": "5福幣"
    }],
    "defineId": "b1dffba5c02f4fe19f3ac766f3432018",
    "remainingTimes": 45,
    "hasDrawed": true,
    "prizeInfo": [{
      "level": 1,
      "picUrlDesc": "http://qdtalk.com/wp-content/uploads/2017/09/1-2.png",
      "prizeId": "436066c40529401287658bfd67c1d346",
      "commodityName": "3福幣"
    }, {
      "level": 2,
      "picUrlDesc": "http://qdtalk.com/wp-content/uploads/2017/09/2-2.png",
      "prizeId": "acdcb838bda74ec8b1fd202234f852ec",
      "commodityName": "200優惠劵"
    }, {
      "level": 3,
      "picUrlDesc": "http://qdtalk.com/wp-content/uploads/2017/09/3-2.png",
      "prizeId": "484bf4c856b94265960b3e182e9f597f",
      "commodityName": "100優惠劵"
    }, {
      "level": 4,
      "picUrlDesc": "http://qdtalk.com/wp-content/uploads/2017/09/4-2.png",
      "prizeId": "d5c7784c4c4d4a33b141fc1be3b11a71",
      "commodityName": "15福幣"
    }, {
      "level": 5,
      "picUrlDesc": "http://qdtalk.com/wp-content/uploads/2017/09/5-2.png",
      "prizeId": "7221846d585a4bed80bf486f94fcabae",
      "commodityName": "10福幣"
    }, {
      "level": 6,
      "picUrlDesc": "http://qdtalk.com/wp-content/uploads/2017/09/6-1.png",
      "prizeId": "33c6413801fd44c594cbf6642840a614",
      "commodityName": "8福幣"
    }, {
      "level": 7,
      "picUrlDesc": "http://qdtalk.com/wp-content/uploads/2017/09/7-1.png",
      "prizeId": "e453f94905334ea083fca649e87b3308",
      "commodityName": "5福幣"
    }, {
      "level": 8,
      "picUrlDesc":"http://qdtalk.com/wp-content/uploads/2017/09/8-1.png",
      "prizeId": "e8df88de1878428bb58d0cc9152d8849",
      "commodityName": "3"
    }],
    "beginTime": 1506519900000,
    "endTime": 1601446191000,
    "currTime": 1506751791732,
    "title": "獎品豐厚",
    "lotteryDesc": "100中獎$utf8$抓緊機會"
  },
  "success": true
}

部分字段說明


  • prizeDesc:獎品說明,採用「$utf8$」分割,前端截取成數組,進行展現
  • winners:獲獎名單
  • defineId:活動id
  • remainingTimes:剩餘抽獎次數
  • beginTime:活動開始時間
  • endTime活動結束時間
  • currTime:當前時間
  • title:活動標題
  • prizeInfo:獎品信息
  • lotteryDesc:抽獎活動說明規則,同獎品說明prizeDesc

vue開發微信商城項目總結之一–項目介紹
vue開發微信商城項目總結之二–Eslint配置
vue開發微信商城項目總結之三–根據不一樣的開發環境作配置
vue開發微信商城項目總結之四--本地代理處理跨域問題
二維碼.pngsegmentfault

相關文章
相關標籤/搜索