Init project
This commit is contained in:
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [2021] [Li Dong Qi]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1,138 @@
|
||||
<br />
|
||||
|
||||
<div align="center">
|
||||
<img src="https://cdn.jsdelivr.net/gh/buuing/cdn/imgs/lucky-canvas.jpg" width="210" alt="logo" />
|
||||
<h1>lucky-canvas 抽奖插件</h1>
|
||||
<p>一个基于 JavaScript 的跨平台 ( 大转盘 / 九宫格 / 老虎机 ) 抽奖插件</p>
|
||||
<p>
|
||||
<a href="https://github.com/buuing/lucky-canvas/stargazers" target="_black">
|
||||
<img src="https://img.shields.io/github/stars/buuing/lucky-canvas?color=%23ffba15&logo=github&style=flat-square" alt="stars" />
|
||||
</a>
|
||||
<a href="https://github.com/buuing/lucky-canvas/network/members" target="_black">
|
||||
<img src="https://img.shields.io/github/forks/buuing/lucky-canvas?color=%23ffba15&logo=github&style=flat-square" alt="forks" />
|
||||
</a>
|
||||
<a href="https://github.com/buuing" target="_black">
|
||||
<img src="https://img.shields.io/badge/Author-%20buuing%20-7289da.svg?&logo=github&style=flat-square" alt="author" />
|
||||
</a>
|
||||
<a href="https://github.com/buuing/lucky-canvas/blob/master/LICENSE" target="_black">
|
||||
<img src="https://img.shields.io/github/license/buuing/lucky-canvas?color=%232dce89&logo=github&style=flat-square" alt="license" />
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
|适配框架|npm下载量|CDN使用量|
|
||||
| :-: | :-: | :-: |
|
||||
|[`JS` / `JQ` 中使用](https://100px.net/usage/js.html)|<a href="https://www.npmjs.com/package/lucky-canvas" target="_black"><img src="https://img.shields.io/npm/dm/lucky-canvas?color=%23ffba15&logo=npm&style=flat-square" alt="downloads" /></a>|<a href="https://www.jsdelivr.com/package/npm/lucky-canvas" target="_black"><img src="https://data.jsdelivr.com/v1/package/npm/lucky-canvas/badge" alt="downloads" /></a>|
|
||||
|[`Vue` 中使用](https://100px.net/usage/vue.html)|<a href="https://www.npmjs.com/package/@lucky-canvas/vue" target="_black"><img src="https://img.shields.io/npm/dm/@lucky-canvas/vue?color=%23ffba15&logo=npm&style=flat-square" alt="downloads" /></a>|<a href="https://www.jsdelivr.com/package/npm/@lucky-canvas/vue" target="_black"><img src="https://data.jsdelivr.com/v1/package/npm/@lucky-canvas/vue/badge" alt="downloads" /></a>|
|
||||
|[`React` 中使用](https://100px.net/usage/react.html)|<a href="https://www.npmjs.com/package/@lucky-canvas/react" target="_black"><img src="https://img.shields.io/npm/dm/@lucky-canvas/react?color=%23ffba15&logo=npm&style=flat-square" alt="downloads" /></a>|-|
|
||||
|[`UniApp` 中使用](https://100px.net/usage/uni.html)|<a href="https://www.npmjs.com/package/@lucky-canvas/uni" target="_black"><img src="https://img.shields.io/npm/dm/@lucky-canvas/uni?color=%23ffba15&logo=npm&style=flat-square" alt="downloads" /></a>|-|
|
||||
|[`Taro3.x` 中使用](https://100px.net/usage/taro.html)|<a href="https://www.npmjs.com/package/@lucky-canvas/taro" target="_black"><img src="https://img.shields.io/npm/dm/@lucky-canvas/taro?color=%23ffba15&logo=npm&style=flat-square" alt="downloads" /></a>|-|
|
||||
|[`微信小程序` 中使用](https://100px.net/usage/wx.html)|<a href="https://www.npmjs.com/package/@lucky-canvas/mini" target="_black"><img src="https://img.shields.io/npm/dm/@lucky-canvas/mini?color=%23ffba15&logo=npm&style=flat-square" alt="downloads" /></a>|-|
|
||||
|
||||
<br />
|
||||
|
||||
## 官方文档 & Demo演示
|
||||
|
||||
> **中文**:[https://100px.net](https://100px.net)
|
||||
|
||||
> **English**:**If anyone can help translate the document, please contact me** `ldq404@qq.com`
|
||||
|
||||
<br />
|
||||
|
||||
## 在 uni-app 中使用
|
||||
|
||||
### 1. 安装插件
|
||||
|
||||
- 你可以选择通过 `HBuilderX` 导入插件: [https://ext.dcloud.net.cn/plugin?id=3499](https://ext.dcloud.net.cn/plugin?id=3499)
|
||||
|
||||
- 也可以选择通过 `npm` / `yarn` 安装
|
||||
|
||||
```shell
|
||||
# npm 安装:
|
||||
npm install @lucky-canvas/uni
|
||||
|
||||
# yarn 安装:
|
||||
yarn add @lucky-canvas/uni
|
||||
```
|
||||
|
||||
<br />
|
||||
|
||||
### 2. 引入并使用
|
||||
|
||||
```html
|
||||
<view>
|
||||
<!-- 大转盘抽奖 -->
|
||||
<LuckyWheel
|
||||
width="600rpx"
|
||||
height="600rpx"
|
||||
...你的配置
|
||||
/>
|
||||
<!-- 九宫格抽奖 -->
|
||||
<LuckyGrid
|
||||
width="600rpx"
|
||||
height="600rpx"
|
||||
...你的配置
|
||||
/>
|
||||
</view>
|
||||
```
|
||||
|
||||
```js
|
||||
// npm 下载会默认到 node_modules 里面,直接引入包名即可
|
||||
import LuckyWheel from '@lucky-canvas/uni/lucky-wheel' // 大转盘
|
||||
import LuckyGrid from '@lucky-canvas/uni/lucky-grid' // 九宫格
|
||||
|
||||
// 如果你是通过 HBuilderX 导入插件,那你需要指定一下路径
|
||||
// import LuckyWheel from '@/components/@lucky-canvas/uni/lucky-wheel' // 大转盘
|
||||
// import LuckyGrid from '@/components/@lucky-canvas/uni/lucky-grid' // 九宫格
|
||||
|
||||
export default {
|
||||
// 注册组件
|
||||
components: { LuckyWheel, LuckyGrid },
|
||||
}
|
||||
```
|
||||
|
||||
<br />
|
||||
|
||||
### 3. 我提供了一个最基本的 demo 供你用于尝试
|
||||
|
||||
由于 uni-app 渲染 md 的时候会出问题,所以我把 demo 代码放到了文档里
|
||||
|
||||
- [https://100px.net/document/uni-app.html](https://100px.net/document/uni-app.html)
|
||||
|
||||
<br />
|
||||
|
||||
### **4. 补充说明**
|
||||
|
||||
- [**如果用着顺手, 可以在 Github 上面点个 <img height="22" align="top" src="https://img.shields.io/github/stars/buuing/lucky-canvas" /> 支持一下(●'◡'●)**](https://github.com/buuing/lucky-canvas)
|
||||
|
||||
- 另外: 如果你修复了某些bug或兼容, 欢迎提给我, 我会把你展示到官网的贡献者列表当中
|
||||
|
||||
|
||||
<br />
|
||||
|
||||
### 5. 常见问题
|
||||
|
||||
1. 转盘层级太高了, 我的弹窗盖不住怎么办?
|
||||
|
||||
> 答: 因为小程序里canvas是原生组件顶层渲染, 我无法控制canvas的层级, 如果你想盖住它也肯简单, 你可以百度搜索`<cover>`组件
|
||||
|
||||
2. 你这些素材, 图片组件从哪下载?
|
||||
|
||||
> 答: 官网里的任何图片素材, 所使用到的图片资源均为学习交流使用, 请勿将其用于商业用途, 由此产生的任何商业纠纷我这边概不负责
|
||||
|
||||
3. xxx属性怎么使用? xxx方法怎么调用?
|
||||
|
||||
> 答: 自己去看文档, 不然难道要我把代码给你写好吗?
|
||||
|
||||
4. 这个属性的效果与官网的描述不一致?
|
||||
|
||||
> 答: 可能有bug, 你可以去github上的issues去提问 (请认真填写模板)
|
||||
|
||||
5. 为什么这个插件不支持app和其他小程序
|
||||
|
||||
> 答: 没时间, 但是希望志同道合的同学来一起参与uniapp的兼容开发
|
||||
|
||||
---
|
||||
|
||||
<font color="blue">作者留言: 为了使我自己保持心情愉悦, 低于5星的提问我用浏览器插件都屏蔽了</font>
|
||||
@@ -0,0 +1,317 @@
|
||||
<template>
|
||||
<view v-if="isShow" class="lucky-box" :style="{ width: boxWidth + 'px', height: boxHeight + 'px' }">
|
||||
<canvas
|
||||
type="2d"
|
||||
id="lucky-grid"
|
||||
canvas-id="lucky-grid"
|
||||
:style="{ width: boxWidth + 'px', height: boxHeight + 'px' }"
|
||||
></canvas>
|
||||
<image
|
||||
v-if="imgSrc"
|
||||
:src="imgSrc"
|
||||
@load="myLucky.clearCanvas()"
|
||||
:style="{ width: boxWidth + 'px', height: boxHeight + 'px' }"
|
||||
></image>
|
||||
<!-- #ifdef APP-PLUS -->
|
||||
<view v-if="btnShow">
|
||||
<view class="lucky-grid-btn" v-for="(btn, index) in btns" :key="index" @click="toPlay(btn, index)" :style="{
|
||||
top: btn.top + 'px',
|
||||
left: btn.left + 'px',
|
||||
width: btn.width + 'px',
|
||||
height: btn.height + 'px',
|
||||
}"></view>
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
<!-- #ifndef APP-PLUS -->
|
||||
<view v-if="btnShow">
|
||||
<cover-view class="lucky-grid-btn" v-for="(btn, index) in btns" :key="index" @click="toPlay(btn, index)" :style="{
|
||||
top: btn.top + 'px',
|
||||
left: btn.left + 'px',
|
||||
width: btn.width + 'px',
|
||||
height: btn.height + 'px',
|
||||
}"></cover-view>
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
<!-- #ifndef H5 -->
|
||||
<view v-if="myLucky">
|
||||
<div class="lucky-imgs">
|
||||
<div v-for="(block, index) in blocks" :key="index">
|
||||
<div v-if="block.imgs">
|
||||
<div v-for="(img, i) in block.imgs" :key="i">
|
||||
<image :src="img.src" :data-index="index" :data-i="i" @load="e => imgBindload(e, 'blocks')"></image>
|
||||
<image :src="img.activeSrc" :data-index="index" :data-i="i" @load="e => imgBindloadActive(e, 'blocks')"></image>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="lucky-imgs">
|
||||
<div v-for="(prize, index) in prizes" :key="index">
|
||||
<div v-if="prize.imgs">
|
||||
<div v-for="(img, i) in prize.imgs" :key="i">
|
||||
<image :src="img.src" :data-index="index" :data-i="i" @load="e => imgBindload(e, 'prizes')"></image>
|
||||
<image :src="img.activeSrc" :data-index="index" :data-i="i" @load="e => imgBindloadActive(e, 'prizes')"></image>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="lucky-imgs">
|
||||
<div v-for="(btn, index) in buttons" :key="index">
|
||||
<div v-if="btn.imgs">
|
||||
<image v-for="(img, i) in btn.imgs" :key="i" :src="img.src" :data-index="index" :data-i="i" @load="e => imgBindload(e, 'buttons')"></image>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="lucky-imgs">
|
||||
<span v-if="button && button.imgs">
|
||||
<image v-for="(img, i) in button.imgs" :key="i" :src="img.src" :data-i="i" @load="e => imgBindloadBtn(e, 'button')"></image>
|
||||
</span>
|
||||
</div>
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { changeUnits, resolveImage, getImage } from './utils.js'
|
||||
import { LuckyGrid } from '../../lucky-canvas'
|
||||
export default {
|
||||
name: 'lucky-grid',
|
||||
data () {
|
||||
return {
|
||||
imgSrc: '',
|
||||
myLucky: null,
|
||||
canvas: null,
|
||||
isShow: false,
|
||||
boxWidth: 100,
|
||||
boxHeight: 100,
|
||||
dpr: 1,
|
||||
btns: [],
|
||||
btnShow: false,
|
||||
}
|
||||
},
|
||||
props: {
|
||||
width: {
|
||||
type: String,
|
||||
default: '600rpx'
|
||||
},
|
||||
height: {
|
||||
type: String,
|
||||
default: '600rpx'
|
||||
},
|
||||
cols: {
|
||||
type: [String, Number],
|
||||
default: 3,
|
||||
},
|
||||
rows: {
|
||||
type: [String, Number],
|
||||
default: 3,
|
||||
},
|
||||
blocks: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
prizes: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
buttons: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
button: {
|
||||
type: Object,
|
||||
default: undefined
|
||||
},
|
||||
defaultConfig: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
defaultStyle: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
activeStyle: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
// #ifdef APP-PLUS
|
||||
console.error('该抽奖插件的最新版暂不支持app端, 请通过npm安装旧版本【npm i uni-luck-draw@1.3.9】')
|
||||
// #endif
|
||||
// #ifndef APP-PLUS
|
||||
this.initLucky()
|
||||
// #endif
|
||||
},
|
||||
watch: {
|
||||
cols (newData) {
|
||||
this.myLucky && (this.myLucky.cols = newData)
|
||||
},
|
||||
rows (newData) {
|
||||
this.myLucky && (this.myLucky.rows = newData)
|
||||
},
|
||||
blocks (newData) {
|
||||
this.myLucky && (this.myLucky.blocks = newData)
|
||||
},
|
||||
prizes (newData) {
|
||||
this.myLucky && (this.myLucky.prizes = newData)
|
||||
},
|
||||
buttons (newData) {
|
||||
this.myLucky && (this.myLucky.buttons = newData)
|
||||
},
|
||||
button (newData) {
|
||||
this.myLucky && (this.myLucky.button = newData)
|
||||
},
|
||||
defaultStyle (newData) {
|
||||
this.myLucky && (this.myLucky.defaultStyle = newData)
|
||||
},
|
||||
defaultConfig (newData) {
|
||||
this.myLucky && (this.myLucky.defaultConfig = newData)
|
||||
},
|
||||
activeStyle (newData) {
|
||||
this.myLucky && (this.myLucky.activeStyle = newData)
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
async imgBindload (res, name) {
|
||||
const { index, i } = res.currentTarget.dataset
|
||||
const img = this[name][index].imgs[i]
|
||||
resolveImage(img, this.canvas)
|
||||
},
|
||||
async imgBindloadActive (res, name) {
|
||||
const { index, i } = res.currentTarget.dataset
|
||||
const img = this[name][index].imgs[i]
|
||||
resolveImage(img, this.canvas, 'activeSrc', '$activeResolve')
|
||||
},
|
||||
async imgBindloadBtn (res, name) {
|
||||
const { i } = res.currentTarget.dataset
|
||||
const img = this[name].imgs[i]
|
||||
resolveImage(img, this.canvas)
|
||||
},
|
||||
getImage () {
|
||||
return getImage.call(this, 'lucky-grid', this.canvas)
|
||||
},
|
||||
hideCanvas () {
|
||||
// #ifdef MP
|
||||
this.getImage().then(res => {
|
||||
this.imgSrc = res.tempFilePath
|
||||
})
|
||||
// #endif
|
||||
},
|
||||
initLucky () {
|
||||
this.boxWidth = changeUnits(this.width)
|
||||
this.boxHeight = changeUnits(this.height)
|
||||
this.isShow = true
|
||||
// 某些情况下获取不到 canvas
|
||||
this.$nextTick(() => {
|
||||
setTimeout(() => {
|
||||
this.draw()
|
||||
})
|
||||
})
|
||||
},
|
||||
draw () {
|
||||
const _this = this
|
||||
uni.createSelectorQuery().in(this).select('#lucky-grid').fields({
|
||||
node: true, size: true
|
||||
}).exec((res) => {
|
||||
// #ifdef H5
|
||||
res[0].node = document.querySelector('#lucky-grid canvas')
|
||||
// #endif
|
||||
if (!res[0] || !res[0].node) return console.error('lucky-canvas 获取不到 canvas 标签')
|
||||
const { node, width, height } = res[0]
|
||||
const canvas = this.canvas = node
|
||||
const ctx = this.ctx = canvas.getContext('2d')
|
||||
const dpr = this.dpr = uni.getSystemInfoSync().pixelRatio
|
||||
// #ifndef H5
|
||||
canvas.width = width * dpr
|
||||
canvas.height = height * dpr
|
||||
ctx.scale(dpr, dpr)
|
||||
// #endif
|
||||
const myLucky = this.myLucky = new LuckyGrid({
|
||||
// #ifdef H5
|
||||
flag: 'WEB',
|
||||
// #endif
|
||||
// #ifdef MP
|
||||
flag: 'MP-WX',
|
||||
// #endif
|
||||
ctx,
|
||||
dpr,
|
||||
setTimeout,
|
||||
clearTimeout,
|
||||
setInterval,
|
||||
clearInterval,
|
||||
// #ifdef H5
|
||||
rAF: requestAnimationFrame,
|
||||
// #endif
|
||||
unitFunc: (num, unit) => changeUnits(num + unit),
|
||||
afterInit: function () {
|
||||
[..._this.$props.buttons, _this.$props.button].forEach((btn, index) => {
|
||||
if (!btn) return
|
||||
const [left, top, width, height] = this.getGeometricProperty([
|
||||
btn.x,
|
||||
btn.y,
|
||||
btn.col || 1,
|
||||
btn.row || 1
|
||||
])
|
||||
_this.btns[index] = { top, left, width, height }
|
||||
})
|
||||
_this.$forceUpdate()
|
||||
},
|
||||
afterStart: () => {
|
||||
this.imgSrc = ''
|
||||
},
|
||||
}, {
|
||||
...this.$props,
|
||||
width,
|
||||
height,
|
||||
start: (...rest) => {
|
||||
this.$emit('start', ...rest)
|
||||
},
|
||||
end: (...rest) => {
|
||||
this.$emit('end', ...rest)
|
||||
this.hideCanvas()
|
||||
},
|
||||
})
|
||||
this.btnShow = true
|
||||
})
|
||||
},
|
||||
toPlay (btn, index) {
|
||||
this.myLucky.startCallback(btn, this.$props.buttons[index])
|
||||
},
|
||||
init () {
|
||||
this.myLucky.init()
|
||||
},
|
||||
play (...rest) {
|
||||
this.myLucky.play(...rest)
|
||||
},
|
||||
stop (...rest) {
|
||||
this.myLucky.stop(...rest)
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.lucky-box {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.lucky-box canvas {
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
||||
.lucky-grid-btn {
|
||||
position: absolute;
|
||||
background: rgba(0, 0, 0, 0);
|
||||
border-radius: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
.lucky-imgs {
|
||||
width: 0;
|
||||
height: 0;
|
||||
visibility: hidden;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,255 @@
|
||||
<template>
|
||||
<view v-if="isShow" class="lucky-box" :style="{ width: boxWidth + 'px', height: boxHeight + 'px' }">
|
||||
<canvas
|
||||
type="2d"
|
||||
id="lucky-wheel"
|
||||
canvas-id="lucky-wheel"
|
||||
:style="{ width: boxWidth + 'px', height: boxHeight + 'px' }"
|
||||
></canvas>
|
||||
<image
|
||||
v-if="imgSrc"
|
||||
:src="imgSrc"
|
||||
@load="myLucky.clearCanvas()"
|
||||
:style="{ width: boxWidth + 'px', height: boxHeight + 'px' }"
|
||||
></image>
|
||||
<!-- #ifdef APP-PLUS -->
|
||||
<view class="lucky-wheel-btn" @click="toPlay" :style="{ width: btnWidth + 'px', height: btnHeight + 'px' }"></view>
|
||||
<!-- #endif -->
|
||||
<!-- #ifndef APP-PLUS -->
|
||||
<cover-view class="lucky-wheel-btn" @click="toPlay" :style="{ width: btnWidth + 'px', height: btnHeight + 'px' }"></cover-view>
|
||||
<!-- #endif -->
|
||||
<!-- #ifndef H5 -->
|
||||
<view v-if="myLucky">
|
||||
<div class="lucky-imgs">
|
||||
<div v-for="(block, index) in blocks" :key="index">
|
||||
<div v-if="block.imgs">
|
||||
<image v-for="(img, i) in block.imgs" :key="i" :src="img.src" @load="e => imgBindload(e, 'blocks', index, i)"></image>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="lucky-imgs">
|
||||
<div v-for="(prize, index) in prizes" :key="index">
|
||||
<div v-if="prize.imgs">
|
||||
<image v-for="(img, i) in prize.imgs" :key="i" :src="img.src" @load="e => imgBindload(e, 'prizes', index, i)"></image>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="lucky-imgs">
|
||||
<div v-for="(btn, index) in buttons" :key="index">
|
||||
<div v-if="btn.imgs">
|
||||
<image v-for="(img, i) in btn.imgs" :key="i" :src="img.src" @load="e => imgBindload(e, 'buttons', index, i)"></image>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { changeUnits, resolveImage, getImage } from './utils.js'
|
||||
import { LuckyWheel } from '../../lucky-canvas'
|
||||
export default {
|
||||
name: 'lucky-wheel',
|
||||
data () {
|
||||
return {
|
||||
imgSrc: '',
|
||||
myLucky: null,
|
||||
canvas: null,
|
||||
isShow: false,
|
||||
boxWidth: 100,
|
||||
boxHeight: 100,
|
||||
btnWidth: 0,
|
||||
btnHeight: 0,
|
||||
dpr: 1,
|
||||
}
|
||||
},
|
||||
props: {
|
||||
width: {
|
||||
type: String,
|
||||
default: '600rpx'
|
||||
},
|
||||
height: {
|
||||
type: String,
|
||||
default: '600rpx'
|
||||
},
|
||||
blocks: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
prizes: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
buttons: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
defaultConfig: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
defaultStyle: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
},
|
||||
mounted () {
|
||||
// #ifdef APP-PLUS
|
||||
console.error('该抽奖插件的最新版暂不支持app端, 请通过npm安装旧版本【npm i uni-luck-draw@1.3.9】')
|
||||
// #endif
|
||||
// #ifndef APP-PLUS
|
||||
this.initLucky()
|
||||
// #endif
|
||||
},
|
||||
watch: {
|
||||
blocks (newData) {
|
||||
this.myLucky && (this.myLucky.blocks = newData)
|
||||
},
|
||||
prizes (newData) {
|
||||
this.myLucky && (this.myLucky.prizes = newData)
|
||||
},
|
||||
buttons (newData) {
|
||||
this.myLucky && (this.myLucky.buttons = newData)
|
||||
},
|
||||
defaultStyle (newData) {
|
||||
this.myLucky && (this.myLucky.defaultStyle = newData)
|
||||
},
|
||||
defaultConfig (newData) {
|
||||
this.myLucky && (this.myLucky.defaultConfig = newData)
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
async imgBindload (res, name, index, i) {
|
||||
const img = this[name][index].imgs[i]
|
||||
resolveImage(img, this.canvas)
|
||||
},
|
||||
getImage () {
|
||||
return getImage.call(this, 'lucky-wheel', this.canvas)
|
||||
},
|
||||
hideCanvas () {
|
||||
// #ifdef MP
|
||||
this.getImage().then(res => {
|
||||
this.imgSrc = res.tempFilePath
|
||||
})
|
||||
// #endif
|
||||
},
|
||||
initLucky () {
|
||||
this.boxWidth = changeUnits(this.width)
|
||||
this.boxHeight = changeUnits(this.height)
|
||||
this.isShow = true
|
||||
// 某些情况下获取不到 canvas
|
||||
this.$nextTick(() => {
|
||||
setTimeout(() => {
|
||||
this.draw()
|
||||
})
|
||||
})
|
||||
},
|
||||
draw () {
|
||||
const _this = this
|
||||
uni.createSelectorQuery().in(this).select('#lucky-wheel').fields({
|
||||
node: true, size: true
|
||||
}).exec((res) => {
|
||||
// #ifdef H5
|
||||
res[0].node = document.querySelector('#lucky-wheel canvas')
|
||||
// #endif
|
||||
if (!res[0] || !res[0].node) return console.error('lucky-canvas 获取不到 canvas 标签')
|
||||
const { node, width, height } = res[0]
|
||||
const canvas = this.canvas = node
|
||||
const ctx = this.ctx = canvas.getContext('2d')
|
||||
const dpr = this.dpr = uni.getSystemInfoSync().pixelRatio
|
||||
// #ifndef H5
|
||||
canvas.width = width * dpr
|
||||
canvas.height = height * dpr
|
||||
ctx.scale(dpr, dpr)
|
||||
// #endif
|
||||
const Radius = Math.min(width, height) / 2
|
||||
const myLucky = this.myLucky = new LuckyWheel({
|
||||
// #ifdef H5
|
||||
flag: 'WEB',
|
||||
// #endif
|
||||
// #ifdef MP
|
||||
flag: 'MP-WX',
|
||||
// #endif
|
||||
ctx,
|
||||
dpr,
|
||||
setTimeout,
|
||||
clearTimeout,
|
||||
setInterval,
|
||||
clearInterval,
|
||||
// #ifdef H5
|
||||
rAF: requestAnimationFrame,
|
||||
// #endif
|
||||
unitFunc: (num, unit) => changeUnits(num + unit),
|
||||
beforeCreate: function () {
|
||||
ctx.translate(Radius, Radius)
|
||||
},
|
||||
beforeResize: function () {
|
||||
ctx.translate(-Radius, -Radius)
|
||||
},
|
||||
afterInit: function () {
|
||||
// 动态设置按钮
|
||||
_this.btnWidth = this.maxBtnRadius * 2
|
||||
_this.btnHeight = this.maxBtnRadius * 2
|
||||
_this.$forceUpdate()
|
||||
},
|
||||
afterStart: () => {
|
||||
this.imgSrc = ''
|
||||
},
|
||||
}, {
|
||||
...this.$props,
|
||||
width,
|
||||
height,
|
||||
start: (...rest) => {
|
||||
this.$emit('start', ...rest)
|
||||
},
|
||||
end: (...rest) => {
|
||||
this.$emit('end', ...rest)
|
||||
this.hideCanvas()
|
||||
},
|
||||
})
|
||||
})
|
||||
},
|
||||
toPlay (e) {
|
||||
this.myLucky.startCallback()
|
||||
},
|
||||
init () {
|
||||
this.myLucky.init()
|
||||
},
|
||||
play (...rest) {
|
||||
this.myLucky.play(...rest)
|
||||
},
|
||||
stop (...rest) {
|
||||
this.myLucky.stop(...rest)
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.lucky-box {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.lucky-box canvas {
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
||||
.lucky-wheel-btn {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
background: rgba(0, 0, 0, 0);
|
||||
border-radius: 50%;
|
||||
cursor: pointer;
|
||||
}
|
||||
.lucky-imgs {
|
||||
width: 0;
|
||||
height: 0;
|
||||
visibility: hidden;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"_from": "@lucky-canvas/uni",
|
||||
"_id": "@lucky-canvas/uni@0.0.10",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-1K7SPr0FT1PfHRYXEh9CwOA/UqayxQosOA8wkZ3w3dfpoB8dij8Y6QGPKjHOMvHRRD1qFU3AEY7XVytjuktVaw==",
|
||||
"_location": "/@lucky-canvas/uni",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "tag",
|
||||
"registry": true,
|
||||
"raw": "@lucky-canvas/uni",
|
||||
"name": "@lucky-canvas/uni",
|
||||
"escapedName": "@lucky-canvas%2funi",
|
||||
"scope": "@lucky-canvas",
|
||||
"rawSpec": "",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "latest"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#USER",
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@lucky-canvas/uni/-/uni-0.0.10.tgz",
|
||||
"_shasum": "c1b98bb1875049b11840b7f4aa6bfa1f0230fab2",
|
||||
"_spec": "@lucky-canvas/uni",
|
||||
"_where": "/Users/ldq/Desktop/temp/test",
|
||||
"author": {
|
||||
"name": "ldq",
|
||||
"email": "ldq404@qq.com"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"lucky-canvas": "~1.7.19"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "uni-app【大转盘 / 九宫格 / 老虎机】抽奖插件",
|
||||
"files": [
|
||||
"lucky-wheel.vue",
|
||||
"lucky-grid.vue",
|
||||
"slot-machine.vue",
|
||||
"utils.js",
|
||||
"demo.vue"
|
||||
],
|
||||
"keywords": [
|
||||
"uni-app抽奖"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"name": "@lucky-canvas/uni",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"version": "0.0.10"
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
<template>
|
||||
<view v-if="isShow" class="lucky-box" :style="{ width: boxWidth + 'px', height: boxHeight + 'px' }">
|
||||
<canvas
|
||||
type="2d"
|
||||
id="slot-machine"
|
||||
canvas-id="slot-machine"
|
||||
:style="{ width: boxWidth + 'px', height: boxHeight + 'px' }"
|
||||
></canvas>
|
||||
<image
|
||||
v-if="imgSrc"
|
||||
:src="imgSrc"
|
||||
@load="myLucky.clearCanvas()"
|
||||
:style="{ width: boxWidth + 'px', height: boxHeight + 'px' }"
|
||||
></image>
|
||||
<!-- #ifndef H5 -->
|
||||
<view v-if="myLucky">
|
||||
<div class="lucky-imgs">
|
||||
<div v-for="(block, index) in blocks" :key="index">
|
||||
<div v-if="block.imgs">
|
||||
<image v-for="(img, i) in block.imgs" :key="i" :src="img.src" @load="e => imgBindload(e, 'blocks', index, i)"></image>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="lucky-imgs">
|
||||
<div v-for="(prize, index) in prizes" :key="index">
|
||||
<div v-if="prize.imgs">
|
||||
<image v-for="(img, i) in prize.imgs" :key="i" :src="img.src" @load="e => imgBindload(e, 'prizes', index, i)"></image>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</view>
|
||||
<!-- #endif -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { changeUnits, resolveImage, getImage } from './utils.js'
|
||||
import { SlotMachine } from '../../lucky-canvas'
|
||||
export default {
|
||||
name: 'slot-machine',
|
||||
data () {
|
||||
return {
|
||||
imgSrc: '',
|
||||
myLucky: null,
|
||||
canvas: null,
|
||||
isShow: false,
|
||||
boxWidth: 100,
|
||||
boxHeight: 100,
|
||||
btnWidth: 0,
|
||||
btnHeight: 0,
|
||||
dpr: 1,
|
||||
}
|
||||
},
|
||||
props: {
|
||||
width: {
|
||||
type: String,
|
||||
default: '600rpx'
|
||||
},
|
||||
height: {
|
||||
type: String,
|
||||
default: '600rpx'
|
||||
},
|
||||
blocks: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
prizes: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
slots: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
defaultConfig: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
defaultStyle: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
},
|
||||
mounted () {
|
||||
// #ifndef APP-PLUS
|
||||
this.initLucky()
|
||||
// #endif
|
||||
},
|
||||
watch: {
|
||||
blocks (newData) {
|
||||
this.myLucky && (this.myLucky.blocks = newData)
|
||||
},
|
||||
prizes (newData) {
|
||||
this.myLucky && (this.myLucky.prizes = newData)
|
||||
},
|
||||
slots (newData) {
|
||||
this.myLucky && (this.myLucky.slots = newData)
|
||||
},
|
||||
defaultStyle (newData) {
|
||||
this.myLucky && (this.myLucky.defaultStyle = newData)
|
||||
},
|
||||
defaultConfig (newData) {
|
||||
this.myLucky && (this.myLucky.defaultConfig = newData)
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
async imgBindload (res, name, index, i) {
|
||||
const img = this[name][index].imgs[i]
|
||||
resolveImage(img, this.canvas)
|
||||
},
|
||||
getImage () {
|
||||
return getImage.call(this, 'slot-machine', this.canvas)
|
||||
},
|
||||
hideCanvas () {
|
||||
// #ifdef MP
|
||||
this.getImage().then(res => {
|
||||
this.imgSrc = res.tempFilePath
|
||||
})
|
||||
// #endif
|
||||
},
|
||||
initLucky () {
|
||||
this.boxWidth = changeUnits(this.width)
|
||||
this.boxHeight = changeUnits(this.height)
|
||||
this.isShow = true
|
||||
// 某些情况下获取不到 canvas
|
||||
this.$nextTick(() => {
|
||||
setTimeout(() => {
|
||||
this.draw()
|
||||
})
|
||||
})
|
||||
},
|
||||
draw () {
|
||||
const _this = this
|
||||
uni.createSelectorQuery().in(this).select('#slot-machine').fields({
|
||||
node: true, size: true
|
||||
}).exec((res) => {
|
||||
// #ifdef H5
|
||||
res[0].node = document.querySelector('#slot-machine canvas')
|
||||
// #endif
|
||||
if (!res[0] || !res[0].node) return console.error('lucky-canvas 获取不到 canvas 标签')
|
||||
const { node, width, height } = res[0]
|
||||
const canvas = this.canvas = node
|
||||
const ctx = this.ctx = canvas.getContext('2d')
|
||||
const dpr = this.dpr = uni.getSystemInfoSync().pixelRatio
|
||||
// #ifndef H5
|
||||
canvas.width = width * dpr
|
||||
canvas.height = height * dpr
|
||||
ctx.scale(dpr, dpr)
|
||||
// #endif
|
||||
const myLucky = this.myLucky = new SlotMachine({
|
||||
// #ifdef H5
|
||||
flag: 'WEB',
|
||||
// #endif
|
||||
// #ifdef MP
|
||||
flag: 'MP-WX',
|
||||
// #endif
|
||||
ctx,
|
||||
dpr,
|
||||
// #ifndef H5
|
||||
offscreenCanvas: uni.createOffscreenCanvas({ type: '2d' }),
|
||||
// #endif
|
||||
setTimeout,
|
||||
clearTimeout,
|
||||
setInterval,
|
||||
clearInterval,
|
||||
// #ifdef H5
|
||||
rAF: requestAnimationFrame,
|
||||
// #endif
|
||||
unitFunc: (num, unit) => changeUnits(num + unit),
|
||||
afterStart: () => {
|
||||
this.imgSrc = ''
|
||||
},
|
||||
}, {
|
||||
...this.$props,
|
||||
width,
|
||||
height,
|
||||
end: (...rest) => {
|
||||
this.$emit('end', ...rest)
|
||||
this.hideCanvas()
|
||||
},
|
||||
})
|
||||
})
|
||||
},
|
||||
init () {
|
||||
this.myLucky.init()
|
||||
},
|
||||
play (...rest) {
|
||||
this.myLucky.play(...rest)
|
||||
},
|
||||
stop (...rest) {
|
||||
this.myLucky.stop(...rest)
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.lucky-box {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.lucky-box canvas {
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
left: 0;
|
||||
top: 0;
|
||||
}
|
||||
.lucky-imgs {
|
||||
width: 0;
|
||||
height: 0;
|
||||
visibility: hidden;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,82 @@
|
||||
let windowWidth = uni.getSystemInfoSync().windowWidth
|
||||
// uni-app@2.9起, 屏幕最多适配到960, 超出则按375计算
|
||||
if (windowWidth > 960) windowWidth = 375
|
||||
|
||||
export const rpx2px = (value) => {
|
||||
if (typeof value === 'string') value = Number(value.replace(/[a-z]*/g, ''))
|
||||
return windowWidth / 750 * value
|
||||
}
|
||||
|
||||
export const changeUnits = (value) => {
|
||||
return Number(value.replace(/^(\-*[0-9.]*)([a-z%]*)$/, (value, num, unit) => {
|
||||
switch (unit) {
|
||||
case 'px':
|
||||
num *= 1
|
||||
break
|
||||
case 'rpx':
|
||||
num = rpx2px(num)
|
||||
break
|
||||
default:
|
||||
num *= 1
|
||||
break
|
||||
}
|
||||
return num
|
||||
}))
|
||||
}
|
||||
|
||||
export const resolveImage = async (img, canvas, srcName = 'src', resolveName = '$resolve') => {
|
||||
let imgObj
|
||||
// 区分 H5 和小程序
|
||||
if (window) {
|
||||
imgObj = new Image()
|
||||
} else {
|
||||
imgObj = canvas.createImage()
|
||||
}
|
||||
// 成功回调
|
||||
imgObj.onload = () => {
|
||||
img[resolveName](imgObj)
|
||||
}
|
||||
// 失败回调
|
||||
imgObj.onerror = (err) => {
|
||||
console.error(err)
|
||||
// img['$reject']()
|
||||
}
|
||||
// 设置src
|
||||
imgObj.src = img[srcName]
|
||||
}
|
||||
|
||||
// 旧版canvas引入图片的方法
|
||||
// export const resolveImage = async (res, img, imgName = 'src', resolveName = '$resolve') => {
|
||||
// const src = img[imgName]
|
||||
// const $resolve = img[resolveName]
|
||||
// // #ifdef MP
|
||||
// // 如果是base64就调用base64src()方法把图片写入本地, 然后渲染临时路径
|
||||
// if (/^data:image\/([a-z]+);base64,/.test(src)) {
|
||||
// const path = await base64src(src)
|
||||
// $resolve({ ...res.detail, path })
|
||||
// return
|
||||
// }
|
||||
// // #endif
|
||||
// // 如果是本地图片, 直接返回
|
||||
// if (src.indexOf('http') !== 0) {
|
||||
// $resolve({ ...res.detail, path:src })
|
||||
// return
|
||||
// }
|
||||
// // 如果是网络图片, 则通过getImageInfo()方法获取图片宽高
|
||||
// uni.getImageInfo({
|
||||
// src: src,
|
||||
// success: (imgObj) => $resolve(imgObj),
|
||||
// fail: () => console.error('API `uni.getImageInfo` 加载图片失败', src)
|
||||
// })
|
||||
// }
|
||||
|
||||
export function getImage(canvasId, canvas) {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.canvasToTempFilePath({
|
||||
canvas,
|
||||
canvasId,
|
||||
success: res => resolve(res),
|
||||
fail: err => reject(err)
|
||||
}, this)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [2021] [Li Dong Qi]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1,42 @@
|
||||
|
||||
|
||||
<div align="center">
|
||||
<img src="https://cdn.jsdelivr.net/gh/buuing/cdn/imgs/lucky-canvas.png" width="128" alt="logo" />
|
||||
<h1>lucky-canvas 抽奖插件</h1>
|
||||
<p>一个基于 JavaScript 的跨平台 ( 大转盘 / 九宫格 / 老虎机 ) 抽奖插件</p>
|
||||
<p>
|
||||
<a href="https://github.com/buuing/lucky-canvas/stargazers" target="_black">
|
||||
<img src="https://img.shields.io/github/stars/buuing/lucky-canvas?color=%23ffba15&logo=github&style=flat-square" alt="stars" />
|
||||
</a>
|
||||
<a href="https://github.com/buuing/lucky-canvas/network/members" target="_black">
|
||||
<img src="https://img.shields.io/github/forks/buuing/lucky-canvas?color=%23ffba15&logo=github&style=flat-square" alt="forks" />
|
||||
</a>
|
||||
<a href="https://github.com/buuing" target="_black">
|
||||
<img src="https://img.shields.io/badge/Author-%20buuing%20-7289da.svg?&logo=github&style=flat-square" alt="author" />
|
||||
</a>
|
||||
<a href="https://github.com/buuing/lucky-canvas/blob/master/LICENSE" target="_black">
|
||||
<img src="https://img.shields.io/github/license/buuing/lucky-canvas?color=%232dce89&logo=github&style=flat-square" alt="license" />
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
|
||||
## 官方文档 & Demo演示
|
||||
|
||||
> **中文**:[https://100px.net/usage/js.html](https://100px.net/usage/js.html)
|
||||
|
||||
> **English**:**If anyone can help translate the document, please contact me** `ldq404@qq.com`
|
||||
|
||||
|
||||
<br />
|
||||
|
||||
## 在 JS / TS 中使用
|
||||
|
||||
- [跳转官网 查看详情](https://100px.net/usage/js.html)
|
||||
|
||||
<br />
|
||||
|
||||
## 🙏🙏🙏 点个Star
|
||||
|
||||
**如果您觉得这个项目还不错, 可以在 [Github](https://github.com/buuing/lucky-canvas) 上面帮我点个`star`, 支持一下作者 ☜(゚ヮ゚☜)**
|
||||
@@ -0,0 +1 @@
|
||||
module.exports = require('./dist/index.umd.js')
|
||||
@@ -0,0 +1,96 @@
|
||||
{
|
||||
"_from": "lucky-canvas@~1.7.19",
|
||||
"_id": "lucky-canvas@1.7.19",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-Gh6JZg0mc0ej9eG/UdTxwAY/OV2LsOXOF0XOK1lgCfdhMZM3TSphFi65zGL5lTVbFn9mNhieT6X3f3NNL3ihKg==",
|
||||
"_location": "/lucky-canvas",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "lucky-canvas@~1.7.19",
|
||||
"name": "lucky-canvas",
|
||||
"escapedName": "lucky-canvas",
|
||||
"rawSpec": "~1.7.19",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "~1.7.19"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@lucky-canvas/uni"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/lucky-canvas/-/lucky-canvas-1.7.19.tgz",
|
||||
"_shasum": "8983bd1739bb9b228768470508ab4e5c84b8df33",
|
||||
"_spec": "lucky-canvas@~1.7.19",
|
||||
"_where": "/Users/ldq/Desktop/temp/test/node_modules/@lucky-canvas/uni",
|
||||
"author": {
|
||||
"name": "ldq",
|
||||
"email": "ldq404@qq.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/LuckDraw/lucky-canvas/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {},
|
||||
"deprecated": false,
|
||||
"description": "一个基于原生 js 的(大转盘 / 九宫格 / 老虎机)抽奖插件",
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.12.3",
|
||||
"@babel/plugin-transform-runtime": "^7.16.4",
|
||||
"@babel/preset-env": "^7.12.1",
|
||||
"@babel/runtime": "^7.16.3",
|
||||
"@rollup/plugin-commonjs": "^16.0.0",
|
||||
"@rollup/plugin-eslint": "^8.0.1",
|
||||
"@rollup/plugin-json": "^4.1.0",
|
||||
"@rollup/plugin-node-resolve": "^10.0.0",
|
||||
"@rollup/plugin-typescript": "^6.1.0",
|
||||
"@typescript-eslint/parser": "^4.14.0",
|
||||
"babel-plugin-external-helpers": "^6.22.0",
|
||||
"babel-preset-latest": "^6.24.1",
|
||||
"core-js": "^3.19.2",
|
||||
"eslint": "^7.18.0",
|
||||
"eslint-plugin-prettier": "^3.3.1",
|
||||
"prettier": "^2.2.1",
|
||||
"rollup": "^2.33.1",
|
||||
"rollup-plugin-babel": "^4.4.0",
|
||||
"rollup-plugin-delete": "^2.0.0",
|
||||
"rollup-plugin-dts": "^3.0.2",
|
||||
"rollup-plugin-livereload": "^2.0.0",
|
||||
"rollup-plugin-serve": "^1.1.0",
|
||||
"rollup-plugin-terser": "^7.0.2",
|
||||
"rollup-plugin-typescript2": "^0.30.0",
|
||||
"tslib": "^2.3.1",
|
||||
"typescript": "^4.0.5"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"types",
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://100px.net",
|
||||
"jsdelivr": "dist/index.umd.js",
|
||||
"keywords": [
|
||||
"大转盘抽奖",
|
||||
"九宫格抽奖",
|
||||
"老虎机抽奖",
|
||||
"抽奖插件",
|
||||
"js抽奖",
|
||||
"移动端抽奖",
|
||||
"canvas抽奖"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"main": "dist/index.cjs.js",
|
||||
"module": "dist/index.esm.js",
|
||||
"name": "lucky-canvas",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/LuckDraw/lucky-canvas.git",
|
||||
"directory": "packages/lucky-canvas"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rollup --config rollup.config.build.js",
|
||||
"dev": "rollup --config rollup.config.dev.js -w"
|
||||
},
|
||||
"types": "types/index.d.ts",
|
||||
"unpkg": "dist/index.umd.js",
|
||||
"version": "1.7.19"
|
||||
}
|
||||
+761
@@ -0,0 +1,761 @@
|
||||
declare type FontItemType = {
|
||||
text: string;
|
||||
top?: string | number;
|
||||
fontColor?: string;
|
||||
fontSize?: string;
|
||||
fontStyle?: string;
|
||||
fontWeight?: string;
|
||||
lineHeight?: string;
|
||||
};
|
||||
declare type FontExtendType = {
|
||||
wordWrap?: boolean;
|
||||
lengthLimit?: string | number;
|
||||
lineClamp?: number;
|
||||
};
|
||||
declare type ImgType = HTMLImageElement | HTMLCanvasElement;
|
||||
declare type ImgItemType = {
|
||||
src: string;
|
||||
top?: string | number;
|
||||
width?: string;
|
||||
height?: string;
|
||||
formatter?: (img: ImgType) => ImgType;
|
||||
$resolve?: Function;
|
||||
$reject?: Function;
|
||||
};
|
||||
declare type BorderRadiusType = string | number;
|
||||
declare type BackgroundType = string;
|
||||
declare type ShadowType = string;
|
||||
declare type ConfigType = {
|
||||
nodeType?: number;
|
||||
flag: 'WEB' | 'MP-WX' | 'UNI-H5' | 'UNI-MP' | 'TARO-H5' | 'TARO-MP';
|
||||
el?: string;
|
||||
divElement?: HTMLDivElement;
|
||||
canvasElement?: HTMLCanvasElement;
|
||||
ctx: CanvasRenderingContext2D;
|
||||
dpr: number;
|
||||
handleCssUnit?: (num: number, unit: string) => number;
|
||||
rAF?: Function;
|
||||
setTimeout: Function;
|
||||
setInterval: Function;
|
||||
clearTimeout: Function;
|
||||
clearInterval: Function;
|
||||
beforeCreate?: Function;
|
||||
beforeResize?: Function;
|
||||
afterResize?: Function;
|
||||
beforeInit?: Function;
|
||||
afterInit?: Function;
|
||||
beforeDraw?: Function;
|
||||
afterDraw?: Function;
|
||||
afterStart?: Function;
|
||||
};
|
||||
declare type RequireKey = 'width' | 'height';
|
||||
declare type UserConfigType = Partial<Omit<ConfigType, RequireKey>> & Required<Pick<ConfigType, RequireKey>>;
|
||||
declare type Tuple<T, Len extends number, Res extends T[] = []> = Res['length'] extends Len ? Res : Tuple<T, Len, [...Res, T]>;
|
||||
|
||||
interface WatchOptType {
|
||||
handler?: () => Function;
|
||||
immediate?: boolean;
|
||||
deep?: boolean;
|
||||
}
|
||||
|
||||
declare class Lucky {
|
||||
protected readonly version: string;
|
||||
protected readonly config: ConfigType;
|
||||
protected readonly ctx: CanvasRenderingContext2D;
|
||||
protected htmlFontSize: number;
|
||||
protected rAF: Function;
|
||||
protected boxWidth: number;
|
||||
protected boxHeight: number;
|
||||
protected data: {
|
||||
width: string | number;
|
||||
height: string | number;
|
||||
};
|
||||
/**
|
||||
* 公共构造器
|
||||
* @param config
|
||||
*/
|
||||
constructor(config: string | HTMLDivElement | UserConfigType, data: {
|
||||
width: string | number;
|
||||
height: string | number;
|
||||
});
|
||||
/**
|
||||
* 初始化组件大小/单位
|
||||
*/
|
||||
protected resize(): void;
|
||||
/**
|
||||
* 初始化方法
|
||||
*/
|
||||
protected initLucky(): void;
|
||||
/**
|
||||
* 鼠标点击事件
|
||||
* @param e 事件参数
|
||||
*/
|
||||
protected handleClick(e: MouseEvent): void;
|
||||
/**
|
||||
* 根标签的字体大小
|
||||
*/
|
||||
protected setHTMLFontSize(): void;
|
||||
clearCanvas(): void;
|
||||
/**
|
||||
* 设备像素比
|
||||
* window 环境下自动获取, 其余环境手动传入
|
||||
*/
|
||||
protected setDpr(): void;
|
||||
/**
|
||||
* 重置盒子和canvas的宽高
|
||||
*/
|
||||
private resetWidthAndHeight;
|
||||
/**
|
||||
* 根据 dpr 缩放 canvas 并处理位移
|
||||
*/
|
||||
protected zoomCanvas(): void;
|
||||
/**
|
||||
* 从 window 对象上获取一些方法
|
||||
*/
|
||||
private initWindowFunction;
|
||||
/**
|
||||
* 异步加载图片并返回图片的几何信息
|
||||
* @param src 图片路径
|
||||
* @param info 图片信息
|
||||
*/
|
||||
protected loadImg(src: string, info: ImgItemType, resolveName?: string): Promise<ImgType>;
|
||||
/**
|
||||
* 公共绘制图片的方法
|
||||
* @param imgObj 图片对象
|
||||
* @param rectInfo: [x轴位置, y轴位置, 渲染宽度, 渲染高度]
|
||||
*/
|
||||
protected drawImage(ctx: CanvasRenderingContext2D, imgObj: ImgType, ...rectInfo: [...Tuple<number, 4>, ...Partial<Tuple<number, 4>>]): void;
|
||||
/**
|
||||
* 获取长度
|
||||
* @param length 将要转换的长度
|
||||
* @return 返回长度
|
||||
*/
|
||||
protected getLength(length: string | number | undefined): number;
|
||||
/**
|
||||
* 转换单位
|
||||
* @param { string } value 将要转换的值
|
||||
* @param { number } denominator 分子
|
||||
* @return { number } 返回新的字符串
|
||||
*/
|
||||
protected changeUnits(value: string, denominator?: number): number;
|
||||
/**
|
||||
* 计算图片的渲染宽高
|
||||
* @param imgObj 图片标签元素
|
||||
* @param imgInfo 图片信息
|
||||
* @param maxWidth 最大宽度
|
||||
* @param maxHeight 最大高度
|
||||
* @return [渲染宽度, 渲染高度]
|
||||
*/
|
||||
protected computedWidthAndHeight(imgObj: ImgType, imgInfo: ImgItemType, maxWidth: number, maxHeight: number): [number, number];
|
||||
/**
|
||||
* 转换并获取宽度
|
||||
* @param width 将要转换的宽度
|
||||
* @param maxWidth 最大宽度
|
||||
* @return 返回相对宽度
|
||||
*/
|
||||
protected getWidth(width: string | number | undefined, maxWidth: number): number;
|
||||
/**
|
||||
* 转换并获取高度
|
||||
* @param height 将要转换的高度
|
||||
* @param maxHeight 最大高度
|
||||
* @return 返回相对高度
|
||||
*/
|
||||
protected getHeight(height: string | number | undefined, maxHeight: number): number;
|
||||
/**
|
||||
* 获取相对(居中)X坐标
|
||||
* @param width
|
||||
* @param col
|
||||
*/
|
||||
protected getOffsetX(width: number, maxWidth?: number): number;
|
||||
protected getOffscreenCanvas(width: number, height: number): {
|
||||
_offscreenCanvas: HTMLCanvasElement;
|
||||
_ctx: CanvasRenderingContext2D;
|
||||
} | void;
|
||||
/**
|
||||
* 添加一个新的响应式数据 (临时)
|
||||
* @param data 数据
|
||||
* @param key 属性
|
||||
* @param value 新值
|
||||
*/
|
||||
$set(data: object, key: string | number, value: any): void;
|
||||
/**
|
||||
* 添加一个属性计算 (临时)
|
||||
* @param data 源数据
|
||||
* @param key 属性名
|
||||
* @param callback 回调函数
|
||||
*/
|
||||
protected $computed(data: object, key: string, callback: Function): void;
|
||||
/**
|
||||
* 添加一个观察者 create user watcher
|
||||
* @param expr 表达式
|
||||
* @param handler 回调函数
|
||||
* @param watchOpt 配置参数
|
||||
* @return 卸载当前观察者的函数 (暂未返回)
|
||||
*/
|
||||
protected $watch(expr: string | Function, handler: Function | WatchOptType, watchOpt?: WatchOptType): Function;
|
||||
}
|
||||
|
||||
declare type PrizeFontType$2 = FontItemType & FontExtendType;
|
||||
declare type ButtonFontType$1 = FontItemType & {};
|
||||
declare type BlockImgType$2 = ImgItemType & {
|
||||
rotate?: boolean;
|
||||
};
|
||||
declare type PrizeImgType$2 = ImgItemType & {};
|
||||
declare type ButtonImgType$1 = ImgItemType & {};
|
||||
declare type BlockType$2 = {
|
||||
padding?: string;
|
||||
background?: BackgroundType;
|
||||
imgs?: Array<BlockImgType$2>;
|
||||
};
|
||||
declare type PrizeType$2 = {
|
||||
range?: number;
|
||||
background?: BackgroundType;
|
||||
fonts?: Array<PrizeFontType$2>;
|
||||
imgs?: Array<PrizeImgType$2>;
|
||||
};
|
||||
declare type ButtonType$1 = {
|
||||
radius?: string;
|
||||
pointer?: boolean;
|
||||
background?: BackgroundType;
|
||||
fonts?: Array<ButtonFontType$1>;
|
||||
imgs?: Array<ButtonImgType$1>;
|
||||
};
|
||||
declare type DefaultConfigType$2 = {
|
||||
gutter?: string | number;
|
||||
offsetDegree?: number;
|
||||
speed?: number;
|
||||
speedFunction?: string;
|
||||
accelerationTime?: number;
|
||||
decelerationTime?: number;
|
||||
stopRange?: number;
|
||||
};
|
||||
declare type DefaultStyleType$2 = {
|
||||
background?: BackgroundType;
|
||||
fontColor?: PrizeFontType$2['fontColor'];
|
||||
fontSize?: PrizeFontType$2['fontSize'];
|
||||
fontStyle?: PrizeFontType$2['fontStyle'];
|
||||
fontWeight?: PrizeFontType$2['fontWeight'];
|
||||
lineHeight?: PrizeFontType$2['lineHeight'];
|
||||
wordWrap?: PrizeFontType$2['wordWrap'];
|
||||
lengthLimit?: PrizeFontType$2['lengthLimit'];
|
||||
lineClamp?: PrizeFontType$2['lineClamp'];
|
||||
};
|
||||
declare type StartCallbackType$1 = (e: MouseEvent) => void;
|
||||
declare type EndCallbackType$2 = (prize: object) => void;
|
||||
interface LuckyWheelConfig {
|
||||
width: string | number;
|
||||
height: string | number;
|
||||
blocks?: Array<BlockType$2>;
|
||||
prizes?: Array<PrizeType$2>;
|
||||
buttons?: Array<ButtonType$1>;
|
||||
defaultConfig?: DefaultConfigType$2;
|
||||
defaultStyle?: DefaultStyleType$2;
|
||||
start?: StartCallbackType$1;
|
||||
end?: EndCallbackType$2;
|
||||
}
|
||||
|
||||
declare class LuckyWheel extends Lucky {
|
||||
private blocks;
|
||||
private prizes;
|
||||
private buttons;
|
||||
private defaultConfig;
|
||||
private defaultStyle;
|
||||
private _defaultConfig;
|
||||
private _defaultStyle;
|
||||
private startCallback?;
|
||||
private endCallback?;
|
||||
private Radius;
|
||||
private prizeRadius;
|
||||
private prizeDeg;
|
||||
private prizeRadian;
|
||||
private rotateDeg;
|
||||
private maxBtnRadius;
|
||||
private startTime;
|
||||
private endTime;
|
||||
private stopDeg;
|
||||
private endDeg;
|
||||
private FPS;
|
||||
/**
|
||||
* 游戏当前的阶段
|
||||
* step = 0 时, 游戏尚未开始
|
||||
* step = 1 时, 此时处于加速阶段
|
||||
* step = 2 时, 此时处于匀速阶段
|
||||
* step = 3 时, 此时处于减速阶段
|
||||
*/
|
||||
private step;
|
||||
/**
|
||||
* 中奖索引
|
||||
* prizeFlag = undefined 时, 处于开始抽奖阶段, 正常旋转
|
||||
* prizeFlag >= 0 时, 说明stop方法被调用, 并且传入了中奖索引
|
||||
* prizeFlag === -1 时, 说明stop方法被调用, 并且传入了负值, 本次抽奖无效
|
||||
*/
|
||||
private prizeFlag;
|
||||
private ImageCache;
|
||||
/**
|
||||
* 大转盘构造器
|
||||
* @param config 配置项
|
||||
* @param data 抽奖数据
|
||||
*/
|
||||
constructor(config: UserConfigType, data: LuckyWheelConfig);
|
||||
protected resize(): void;
|
||||
protected initLucky(): void;
|
||||
/**
|
||||
* 初始化数据
|
||||
* @param data
|
||||
*/
|
||||
private initData;
|
||||
/**
|
||||
* 初始化属性计算
|
||||
*/
|
||||
private initComputed;
|
||||
/**
|
||||
* 初始化观察者
|
||||
*/
|
||||
private initWatch;
|
||||
/**
|
||||
* 初始化 canvas 抽奖
|
||||
*/
|
||||
init(): Promise<void>;
|
||||
private initImageCache;
|
||||
/**
|
||||
* canvas点击事件
|
||||
* @param e 事件参数
|
||||
*/
|
||||
protected handleClick(e: MouseEvent): void;
|
||||
/**
|
||||
* 根据索引单独加载指定图片并缓存
|
||||
* @param cellName 模块名称
|
||||
* @param cellIndex 模块索引
|
||||
* @param imgName 模块对应的图片缓存
|
||||
* @param imgIndex 图片索引
|
||||
*/
|
||||
private loadAndCacheImg;
|
||||
private drawBlock;
|
||||
/**
|
||||
* 开始绘制
|
||||
*/
|
||||
protected draw(): void;
|
||||
/**
|
||||
* 刻舟求剑
|
||||
*/
|
||||
private carveOnGunwaleOfAMovingBoat;
|
||||
/**
|
||||
* 对外暴露: 开始抽奖方法
|
||||
*/
|
||||
play(): void;
|
||||
/**
|
||||
* 对外暴露: 缓慢停止方法
|
||||
* @param index 中奖索引
|
||||
*/
|
||||
stop(index?: number): void;
|
||||
/**
|
||||
* 实际开始执行方法
|
||||
* @param num 记录帧动画执行多少次
|
||||
*/
|
||||
private run;
|
||||
/**
|
||||
* 换算渲染坐标
|
||||
* @param x
|
||||
* @param y
|
||||
*/
|
||||
protected conversionAxis(x: number, y: number): [number, number];
|
||||
}
|
||||
|
||||
declare type PrizeFontType$1 = FontItemType & FontExtendType;
|
||||
declare type ButtonFontType = FontItemType & FontExtendType;
|
||||
declare type BlockImgType$1 = ImgItemType & {};
|
||||
declare type PrizeImgType$1 = ImgItemType & {
|
||||
activeSrc?: string;
|
||||
};
|
||||
declare type ButtonImgType = ImgItemType & {};
|
||||
declare type BlockType$1 = {
|
||||
borderRadius?: BorderRadiusType;
|
||||
background?: BackgroundType;
|
||||
padding?: string;
|
||||
paddingTop?: string | number;
|
||||
paddingRight?: string | number;
|
||||
paddingBottom?: string | number;
|
||||
paddingLeft?: string | number;
|
||||
imgs?: Array<BlockImgType$1>;
|
||||
};
|
||||
declare type CellType<T, U> = {
|
||||
x: number;
|
||||
y: number;
|
||||
col?: number;
|
||||
row?: number;
|
||||
borderRadius?: BorderRadiusType;
|
||||
background?: BackgroundType;
|
||||
shadow?: ShadowType;
|
||||
fonts?: Array<T>;
|
||||
imgs?: Array<U>;
|
||||
};
|
||||
declare type PrizeType$1 = CellType<PrizeFontType$1, PrizeImgType$1> & {
|
||||
range?: number;
|
||||
disabled?: boolean;
|
||||
};
|
||||
declare type ButtonType = CellType<ButtonFontType, ButtonImgType> & {
|
||||
callback?: Function;
|
||||
};
|
||||
declare type DefaultConfigType$1 = {
|
||||
gutter?: number;
|
||||
speed?: number;
|
||||
accelerationTime?: number;
|
||||
decelerationTime?: number;
|
||||
};
|
||||
declare type DefaultStyleType$1 = {
|
||||
borderRadius?: BorderRadiusType;
|
||||
background?: BackgroundType;
|
||||
shadow?: ShadowType;
|
||||
fontColor?: PrizeFontType$1['fontColor'];
|
||||
fontSize?: PrizeFontType$1['fontSize'];
|
||||
fontStyle?: PrizeFontType$1['fontStyle'];
|
||||
fontWeight?: PrizeFontType$1['fontWeight'];
|
||||
lineHeight?: PrizeFontType$1['lineHeight'];
|
||||
wordWrap?: PrizeFontType$1['wordWrap'];
|
||||
lengthLimit?: PrizeFontType$1['lengthLimit'];
|
||||
lineClamp?: PrizeFontType$1['lineClamp'];
|
||||
};
|
||||
declare type ActiveStyleType = {
|
||||
background?: BackgroundType;
|
||||
shadow?: ShadowType;
|
||||
fontColor?: PrizeFontType$1['fontColor'];
|
||||
fontSize?: PrizeFontType$1['fontSize'];
|
||||
fontStyle?: PrizeFontType$1['fontStyle'];
|
||||
fontWeight?: PrizeFontType$1['fontWeight'];
|
||||
lineHeight?: PrizeFontType$1['lineHeight'];
|
||||
};
|
||||
declare type RowsType = number;
|
||||
declare type ColsType = number;
|
||||
declare type StartCallbackType = (e: MouseEvent, button?: ButtonType) => void;
|
||||
declare type EndCallbackType$1 = (prize: object) => void;
|
||||
interface LuckyGridConfig {
|
||||
width: string | number;
|
||||
height: string | number;
|
||||
rows?: RowsType;
|
||||
cols?: ColsType;
|
||||
blocks?: Array<BlockType$1>;
|
||||
prizes?: Array<PrizeType$1>;
|
||||
buttons?: Array<ButtonType>;
|
||||
button?: ButtonType;
|
||||
defaultConfig?: DefaultConfigType$1;
|
||||
defaultStyle?: DefaultStyleType$1;
|
||||
activeStyle?: ActiveStyleType;
|
||||
start?: StartCallbackType;
|
||||
end?: EndCallbackType$1;
|
||||
}
|
||||
|
||||
declare class LuckyGrid extends Lucky {
|
||||
private rows;
|
||||
private cols;
|
||||
private blocks;
|
||||
private prizes;
|
||||
private buttons;
|
||||
private button?;
|
||||
private defaultConfig;
|
||||
private defaultStyle;
|
||||
private activeStyle;
|
||||
private _defaultConfig;
|
||||
private _defaultStyle;
|
||||
private _activeStyle;
|
||||
private startCallback?;
|
||||
private endCallback?;
|
||||
private cellWidth;
|
||||
private cellHeight;
|
||||
private startTime;
|
||||
private endTime;
|
||||
private currIndex;
|
||||
private stopIndex;
|
||||
private endIndex;
|
||||
private demo;
|
||||
private timer;
|
||||
private FPS;
|
||||
/**
|
||||
* 游戏当前的阶段
|
||||
* step = 0 时, 游戏尚未开始
|
||||
* step = 1 时, 此时处于加速阶段
|
||||
* step = 2 时, 此时处于匀速阶段
|
||||
* step = 3 时, 此时处于减速阶段
|
||||
*/
|
||||
private step;
|
||||
/**
|
||||
* 中奖索引
|
||||
* prizeFlag = undefined 时, 处于开始抽奖阶段, 正常旋转
|
||||
* prizeFlag >= 0 时, 说明stop方法被调用, 并且传入了中奖索引
|
||||
* prizeFlag === -1 时, 说明stop方法被调用, 并且传入了负值, 本次抽奖无效
|
||||
*/
|
||||
private prizeFlag;
|
||||
private cells;
|
||||
private prizeArea;
|
||||
private ImageCache;
|
||||
/**
|
||||
* 九宫格构造器
|
||||
* @param config 配置项
|
||||
* @param data 抽奖数据
|
||||
*/
|
||||
constructor(config: UserConfigType, data: LuckyGridConfig);
|
||||
protected resize(): void;
|
||||
protected initLucky(): void;
|
||||
/**
|
||||
* 初始化数据
|
||||
* @param data
|
||||
*/
|
||||
private initData;
|
||||
/**
|
||||
* 初始化属性计算
|
||||
*/
|
||||
private initComputed;
|
||||
/**
|
||||
* 初始化观察者
|
||||
*/
|
||||
private initWatch;
|
||||
/**
|
||||
* 初始化 canvas 抽奖
|
||||
*/
|
||||
init(): Promise<void>;
|
||||
private initImageCache;
|
||||
/**
|
||||
* canvas点击事件
|
||||
* @param e 事件参数
|
||||
*/
|
||||
protected handleClick(e: MouseEvent): void;
|
||||
/**
|
||||
* 根据索引单独加载指定图片并缓存
|
||||
* @param cellName 模块名称
|
||||
* @param cellIndex 模块索引
|
||||
* @param imgName 模块对应的图片缓存
|
||||
* @param imgIndex 图片索引
|
||||
*/
|
||||
private loadAndCacheImg;
|
||||
/**
|
||||
* 绘制九宫格抽奖
|
||||
*/
|
||||
protected draw(): void;
|
||||
/**
|
||||
* 处理背景色
|
||||
* @param x
|
||||
* @param y
|
||||
* @param width
|
||||
* @param height
|
||||
* @param background
|
||||
* @param isActive
|
||||
*/
|
||||
private handleBackground;
|
||||
/**
|
||||
* 刻舟求剑
|
||||
*/
|
||||
private carveOnGunwaleOfAMovingBoat;
|
||||
/**
|
||||
* 对外暴露: 开始抽奖方法
|
||||
*/
|
||||
play(): void;
|
||||
/**
|
||||
* 对外暴露: 缓慢停止方法
|
||||
* @param index 中奖索引
|
||||
*/
|
||||
stop(index?: number): void;
|
||||
/**
|
||||
* 实际开始执行方法
|
||||
* @param num 记录帧动画执行多少次
|
||||
*/
|
||||
private run;
|
||||
/**
|
||||
* 计算奖品格子的几何属性
|
||||
* @param { array } [...矩阵坐标, col, row]
|
||||
* @return { array } [...真实坐标, width, height]
|
||||
*/
|
||||
private getGeometricProperty;
|
||||
/**
|
||||
* 换算渲染坐标
|
||||
* @param x
|
||||
* @param y
|
||||
*/
|
||||
protected conversionAxis(x: number, y: number): [number, number];
|
||||
}
|
||||
|
||||
declare type PrizeFontType = FontItemType & FontExtendType;
|
||||
declare type BlockImgType = ImgItemType & {};
|
||||
declare type PrizeImgType = ImgItemType;
|
||||
declare type BlockType = {
|
||||
borderRadius?: BorderRadiusType;
|
||||
background?: BackgroundType;
|
||||
padding?: string;
|
||||
paddingTop?: string | number;
|
||||
paddingRight?: string | number;
|
||||
paddingBottom?: string | number;
|
||||
paddingLeft?: string | number;
|
||||
imgs?: Array<BlockImgType>;
|
||||
};
|
||||
declare type PrizeType = {
|
||||
borderRadius?: BorderRadiusType;
|
||||
background?: BackgroundType;
|
||||
fonts?: Array<PrizeFontType>;
|
||||
imgs?: Array<PrizeImgType>;
|
||||
};
|
||||
declare type SlotType = {
|
||||
order?: number[];
|
||||
speed?: number;
|
||||
direction?: 1 | -1;
|
||||
};
|
||||
declare type DefaultConfigType = {
|
||||
/**
|
||||
* vertical 为纵向旋转
|
||||
* horizontal 为横向旋转
|
||||
*/
|
||||
mode?: 'vertical' | 'horizontal';
|
||||
/**
|
||||
* 当排列方向 = `vertical`时
|
||||
* 1 bottom to top
|
||||
* -1 top to bottom
|
||||
* 当排列方向 = `horizontal`时
|
||||
* 1 right to left
|
||||
* -1 left to right
|
||||
*/
|
||||
direction?: 1 | -1;
|
||||
rowSpacing?: number;
|
||||
colSpacing?: number;
|
||||
speed?: number;
|
||||
accelerationTime?: number;
|
||||
decelerationTime?: number;
|
||||
};
|
||||
declare type DefaultStyleType = {
|
||||
borderRadius?: BorderRadiusType;
|
||||
background?: BackgroundType;
|
||||
fontColor?: PrizeFontType['fontColor'];
|
||||
fontSize?: PrizeFontType['fontSize'];
|
||||
fontStyle?: PrizeFontType['fontStyle'];
|
||||
fontWeight?: PrizeFontType['fontWeight'];
|
||||
lineHeight?: PrizeFontType['lineHeight'];
|
||||
wordWrap?: PrizeFontType['wordWrap'];
|
||||
lengthLimit?: PrizeFontType['lengthLimit'];
|
||||
lineClamp?: PrizeFontType['lineClamp'];
|
||||
};
|
||||
declare type EndCallbackType = (prize: PrizeType | undefined) => void;
|
||||
interface SlotMachineConfig {
|
||||
width: string | number;
|
||||
height: string | number;
|
||||
blocks?: Array<BlockType>;
|
||||
prizes?: Array<PrizeType>;
|
||||
slots?: Array<SlotType>;
|
||||
defaultConfig?: DefaultConfigType;
|
||||
defaultStyle?: DefaultStyleType;
|
||||
end?: EndCallbackType;
|
||||
}
|
||||
|
||||
declare class SlotMachine extends Lucky {
|
||||
private blocks;
|
||||
private prizes;
|
||||
private slots;
|
||||
private defaultConfig;
|
||||
private _defaultConfig;
|
||||
private defaultStyle;
|
||||
private _defaultStyle;
|
||||
private endCallback;
|
||||
private _offscreenCanvas?;
|
||||
private cellWidth;
|
||||
private cellHeight;
|
||||
private cellAndSpacing;
|
||||
private widthAndSpacing;
|
||||
private heightAndSpacing;
|
||||
private FPS;
|
||||
private scroll;
|
||||
private stopScroll;
|
||||
private endScroll;
|
||||
private startTime;
|
||||
private endTime;
|
||||
/**
|
||||
* 游戏当前的阶段
|
||||
* step = 0 时, 游戏尚未开始
|
||||
* step = 1 时, 此时处于加速阶段
|
||||
* step = 2 时, 此时处于匀速阶段
|
||||
* step = 3 时, 此时处于减速阶段
|
||||
*/
|
||||
private step;
|
||||
/**
|
||||
* 中奖索引
|
||||
* prizeFlag = undefined 时, 处于开始抽奖阶段, 正常旋转
|
||||
* prizeFlag >= 0 时, 说明stop方法被调用, 并且传入了中奖索引
|
||||
* prizeFlag === -1 时, 说明stop方法被调用, 并且传入了负值, 本次抽奖无效
|
||||
*/
|
||||
private prizeFlag;
|
||||
private prizeArea?;
|
||||
private ImageCache;
|
||||
/**
|
||||
* 老虎机构造器
|
||||
* @param config 配置项
|
||||
* @param data 抽奖数据
|
||||
*/
|
||||
constructor(config: UserConfigType, data: SlotMachineConfig);
|
||||
protected resize(): void;
|
||||
protected initLucky(): void;
|
||||
/**
|
||||
* 初始化数据
|
||||
* @param data
|
||||
*/
|
||||
private initData;
|
||||
/**
|
||||
* 初始化属性计算
|
||||
*/
|
||||
private initComputed;
|
||||
/**
|
||||
* 初始化观察者
|
||||
*/
|
||||
private initWatch;
|
||||
/**
|
||||
* 初始化 canvas 抽奖
|
||||
*/
|
||||
init(): Promise<void>;
|
||||
private initImageCache;
|
||||
/**
|
||||
* 根据索引单独加载指定图片并缓存
|
||||
* @param cellName 模块名称
|
||||
* @param cellIndex 模块索引
|
||||
* @param imgName 模块对应的图片缓存
|
||||
* @param imgIndex 图片索引
|
||||
*/
|
||||
private loadAndCacheImg;
|
||||
/**
|
||||
* 绘制离屏canvas
|
||||
*/
|
||||
protected drawOffscreenCanvas(): void;
|
||||
/**
|
||||
* 绘制背景区域
|
||||
*/
|
||||
protected drawBlocks(): SlotMachine['prizeArea'];
|
||||
/**
|
||||
* 绘制老虎机抽奖
|
||||
*/
|
||||
protected draw(): void;
|
||||
/**
|
||||
* 刻舟求剑
|
||||
*/
|
||||
private carveOnGunwaleOfAMovingBoat;
|
||||
/**
|
||||
* 对外暴露: 开始抽奖方法
|
||||
*/
|
||||
play(): void;
|
||||
stop(index: number | number[]): void;
|
||||
/**
|
||||
* 让游戏动起来
|
||||
* @param num 记录帧动画执行多少次
|
||||
*/
|
||||
private run;
|
||||
private displacement;
|
||||
private displacementWidthOrHeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* 切割圆角
|
||||
* @param img 将要裁剪的图片对象
|
||||
* @param radius 裁剪的圆角半径
|
||||
* @returns 返回一个离屏 canvas 用于渲染
|
||||
*/
|
||||
declare const cutRound: (img: ImgType, radius: number) => ImgType;
|
||||
/**
|
||||
* 透明度
|
||||
* @param img 将要处理的图片对象
|
||||
* @param opacity 透明度
|
||||
* @returns 返回一个离屏 canvas 用于渲染
|
||||
*/
|
||||
declare const opacity: (img: ImgType, opacity: number) => ImgType;
|
||||
|
||||
export { LuckyGrid, LuckyWheel, SlotMachine, cutRound, opacity };
|
||||
@@ -0,0 +1,213 @@
|
||||
<template>
|
||||
<view class="page-select-city">
|
||||
<uni-search-bar class="search" :placeholder="`搜索${title}`" bgColor="#fff" @confirm="search" @input="input">
|
||||
</uni-search-bar>
|
||||
<view class="city-box">
|
||||
<image :src="webUrl+'/20220903142929759087.png'" mode="scaleToFill"></image>
|
||||
<text class="main">{{location}}</text>
|
||||
<text class="sub">当前定位</text>
|
||||
</view>
|
||||
|
||||
<view class="group" v-if="topList.length>0">
|
||||
<view class="title" style="font-size: 28rpx;">特别推荐</view>
|
||||
<view class="list">
|
||||
<view class="item" v-for="item in topList" :key="item" @click="select(item)">
|
||||
<view class="has-goods" v-if="item.hasGoods==0 && back==='specialty'">{{labelText}}</view>
|
||||
<image :src="item.icon" mode="scaleToFill"></image>
|
||||
<view class="city-name">{{item.cityName}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="group">
|
||||
<view class="title" style="font-size: 28rpx;">全国城市</view>
|
||||
|
||||
<view class="group" style="margin-left: 0;margin-right: 0;" v-for="group in list">
|
||||
<view class="title">{{group.label}}</view>
|
||||
<view class="list">
|
||||
<view class="item" v-for="item in group.city" :key="item" @click="select(item)">
|
||||
<view class="has-goods" v-if="item.hasGoods==0 && back==='specialty'">{{labelText}}</view>
|
||||
<image :src="item.icon" mode="scaleToFill"></image>
|
||||
<view class="city-name">{{item.cityName}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
fetchCity
|
||||
} from "@/api/shop";
|
||||
import {
|
||||
getHotelCityList
|
||||
} from "@/api/inn";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
webUrl: this.$VUE_APP_RESOURCES_URL,
|
||||
back: "",
|
||||
location: "",
|
||||
title: "",
|
||||
list: [],
|
||||
topCount: 0,
|
||||
topList: [],
|
||||
labelText: "暂无特产"
|
||||
}
|
||||
},
|
||||
onLoad: function(options) {
|
||||
this.back = options.back;
|
||||
this.location = options.city;
|
||||
|
||||
if (this.back === "specialty") {
|
||||
this.title = "特产";
|
||||
uni.setNavigationBarTitle({
|
||||
title: this.title
|
||||
});
|
||||
}
|
||||
|
||||
this.fetchList();
|
||||
},
|
||||
methods: {
|
||||
fetchList() {
|
||||
switch (this.back) {
|
||||
case "specialty":
|
||||
fetchCity().then(res => {
|
||||
if (res.success) {
|
||||
this.topList = res.data.tops;
|
||||
this.list = res.data.group;
|
||||
}
|
||||
})
|
||||
break;
|
||||
case "cloud":
|
||||
getHotelCityList().then(res=>{
|
||||
this.list = res.data;
|
||||
})
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
select(item) {
|
||||
uni.setStorageSync("cityName", item.cityName)
|
||||
uni.navigateBack()
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.page-select-city {
|
||||
min-height: 100vh;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.search {
|
||||
.uni-searchbar {
|
||||
padding: 20rpx 32rpx 12rpx !important;
|
||||
|
||||
.uni-searchbar__box {
|
||||
border-radius: 44px !important;
|
||||
background: #F6F6F6 !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.city-box {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
margin-left: 32rpx;
|
||||
padding: 8rpx 18rpx 8rpx 16rpx;
|
||||
border-radius: 30px;
|
||||
background: #fff;
|
||||
|
||||
image {
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
margin-right: 4rpx;
|
||||
}
|
||||
|
||||
.main {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
line-height: 48rpx;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.sub {
|
||||
margin: 14rpx 0 0 22rpx;
|
||||
font-size: 24rpx;
|
||||
font-weight: 400;
|
||||
line-height: 34rpx;
|
||||
color: #999999;
|
||||
}
|
||||
}
|
||||
|
||||
.group {
|
||||
margin: 40rpx 32rpx 0;
|
||||
|
||||
.title {
|
||||
font-size: 24rpx;
|
||||
font-weight: bold;
|
||||
line-height: 34rpx;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
margin-top: 18rpx;
|
||||
|
||||
.item {
|
||||
position: relative;
|
||||
width: 154rpx;
|
||||
height: 154rpx;
|
||||
// height: 214rpx;
|
||||
box-sizing: border-box;
|
||||
margin: 0 22rpx 24rpx 0;
|
||||
// border: 2rpx solid #707070;
|
||||
border-radius: 8px;
|
||||
|
||||
image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 8px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.has-goods {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
padding: 6rpx;
|
||||
border-radius: 8px 0 8px 0;
|
||||
background: #f66;
|
||||
color: #fff;
|
||||
font-size: 24rpx;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.city-name {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 48rpx;
|
||||
line-height: 48rpx;
|
||||
border-radius: 0 0 8px 8px;
|
||||
background: rgba(0, 0, 0, .2);
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.item:nth-child(4n) {
|
||||
margin-right: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,360 @@
|
||||
<template>
|
||||
<view class="page-v4">
|
||||
<image class="header-img img" :src="investmentTopImage" mode="widthFix"></image>
|
||||
|
||||
<view class="body flex flex-col flex-wrap jc-center ai-center">
|
||||
<view class="h1">{{ investmentTitle }}</view>
|
||||
<view class="red-box flex jc-center ai-center">
|
||||
<image class="icon-fire" :src="webUrl+'/20221118092713277343.png'" mode="scaleToFill"></image>
|
||||
<view>目前已有
|
||||
<text>{{ total }}</text>
|
||||
人参加活动
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="form-box">
|
||||
<view class="title tc">申请资料填写</view>
|
||||
<text class="label">选择省市区</text>
|
||||
<view class="custom-input">
|
||||
<CitySelect ref="cityselect" :defaultValue="addressText" @callback="result" :items="district"/>
|
||||
</view>
|
||||
<text class="label">姓名</text>
|
||||
<input class="custom-input" type="text" :value="businessApply.realName" @input="inputKey($event,'realName')"/>
|
||||
<text class="label">电话</text>
|
||||
<input class="custom-input" type="number" :value="businessApply.phone" @input="inputKey($event,'phone')"/>
|
||||
<!-- <text class="label">身份证号码</text>-->
|
||||
<!-- <input class="custom-input" type="idcard" :value="businessApply.idcard" @input="inputKey($event,'idcard')"/>-->
|
||||
<button class="submit-btn" type="default" @click="sumbit">提交申请</button>
|
||||
|
||||
<image class="footer-img img" style="margin-top:30rpx" :src="investmentMainImage" mode="widthFix"
|
||||
@click="goList"></image>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="people-box" v-if="businessApplyList.length">
|
||||
<view class="title tc">最新参与客户</view>
|
||||
<view class="list">
|
||||
<view class="item flex ai-center" :class="{'selected':index==1}" v-for="(item,index) in businessApplyList" :key="item" v-show="index<3">
|
||||
<view class="grid-1 flex ai-center">
|
||||
<image class="icon-horn" :src="webUrl+'/20220218225707839596.png'" mode="scaleToFill"></image>
|
||||
<text>{{ item.realName }}</text>
|
||||
</view>
|
||||
<view class="grid-2">{{ item.phone }}</view>
|
||||
<view>{{ item.disTime }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<image class="footer-img img" :src="investmentBottomImage" mode="widthFix"></image>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import CitySelect from "@/components/CitySelect";
|
||||
import {getCity} from "@/api/user";
|
||||
import {getAttract, investment, saveAttract} from "@/api/shop.js";
|
||||
// import {
|
||||
// queryByType
|
||||
// } from "@/api/public";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
CitySelect
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
webUrl: this.$VUE_APP_RESOURCES_URL,
|
||||
district: [],
|
||||
address: {},
|
||||
addressText: "",
|
||||
total: 0,
|
||||
businessApply: {
|
||||
realName: "",
|
||||
phone: "",
|
||||
idcard: ""
|
||||
},
|
||||
businessApplyList: [],
|
||||
headerImg: null,
|
||||
footerImg: null,
|
||||
investmentTopImage: null,
|
||||
investmentMainImage: null,
|
||||
investmentBottomImage: null,
|
||||
investmentTitle: ""
|
||||
}
|
||||
},
|
||||
onLoad: function () {
|
||||
this.init()
|
||||
this.getCityList()
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
// queryByType("business_info").then(({data}) => {
|
||||
// data.map(item => {
|
||||
// switch (item.label) {
|
||||
// case "招商banner图上":
|
||||
// this.headerImg = item.value;
|
||||
// break;
|
||||
// case "招商banner图下":
|
||||
// this.footerImg = item.value;
|
||||
// break;
|
||||
// case "招商标题":
|
||||
// this.title = item.value;
|
||||
// break;
|
||||
// }
|
||||
// })
|
||||
// });
|
||||
|
||||
investment().then(({data}) => {
|
||||
this.investmentTitle = data.investmentTitle;
|
||||
this.investmentTopImage = data.investmentTopImage;
|
||||
this.investmentMainImage = data.investmentMainImage;
|
||||
this.investmentBottomImage = data.investmentBottomImage;
|
||||
});
|
||||
|
||||
getAttract().then(({data}) => {
|
||||
this.total = data.total
|
||||
this.businessApplyList = data.businessApplyList
|
||||
if (data.businessApply) {
|
||||
this.businessApply = data.businessApply
|
||||
this.address = {
|
||||
province: data.businessApply.provinceName || "",
|
||||
city: data.businessApply.cityName || "",
|
||||
district: data.businessApply.areaName || "",
|
||||
provinceId: data.businessApply.provinceId,
|
||||
cityId: data.businessApply.cityId,
|
||||
areaId: data.businessApply.areaId
|
||||
};
|
||||
this.addressText = `${this.address.province} ${this.address.city} ${this.address.district}`;
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
inputKey(e, key) {
|
||||
this.businessApply[key] = e.detail.value
|
||||
},
|
||||
|
||||
sumbit() {
|
||||
if (this.address.areaId) {
|
||||
this.businessApply.provinceId = this.address.provinceId
|
||||
this.businessApply.cityId = this.address.cityId
|
||||
this.businessApply.areaId = this.address.areaId
|
||||
this.businessApply.uid = uni.getStorageSync("uid")
|
||||
} else {
|
||||
this.$dialog.error("请选择你的地址")
|
||||
return
|
||||
}
|
||||
// || this.businessApply.idcard.length == 0
|
||||
if (this.businessApply.realName.length == 0 || this.businessApply.phone.length == 0) {
|
||||
this.$dialog.error("请完整填写后再提交申请")
|
||||
return
|
||||
}
|
||||
|
||||
saveAttract(this.businessApply).then(res => {
|
||||
this.$dialog.error(res.msg)
|
||||
}).catch(err => this.$dialog.error(err.msg))
|
||||
},
|
||||
|
||||
result(values) {
|
||||
this.address = {
|
||||
province: values.province.name || "",
|
||||
city: values.city.name || "",
|
||||
district: values.district.name || "",
|
||||
provinceId: values.province.id,
|
||||
cityId: values.city.id,
|
||||
areaId: values.district.id
|
||||
};
|
||||
this.addressText = `${this.address.province} ${this.address.city} ${this.address.district}`;
|
||||
},
|
||||
|
||||
getCityList: function () {
|
||||
let that = this;
|
||||
getCity()
|
||||
.then(res => {
|
||||
that.district = res.data;
|
||||
that.ready = true;
|
||||
|
||||
if (this.id) {
|
||||
//设置city_id
|
||||
var pIdx = that.getIndex(that.address.province, that.district);
|
||||
if (pIdx > -1) {
|
||||
var citys = that.district[pIdx].c;
|
||||
var cIdx = that.getIndex(that.address.city, citys);
|
||||
if (cIdx > -1) {
|
||||
var city = citys[cIdx];
|
||||
that.address.city_id = city.v;
|
||||
console.log('city_id:' + city.v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
.catch(err => {
|
||||
that.$dialog.error(err.msg);
|
||||
});
|
||||
},
|
||||
|
||||
goList() {
|
||||
uni.navigateTo({
|
||||
url: './projectList'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.page-v4 {
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.img {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.header-img {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.footer-img {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.icon-fire {
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
margin-right: 18rpx;
|
||||
}
|
||||
|
||||
.body {
|
||||
.h1 {
|
||||
margin-top: 40rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
line-height: 48rpx;
|
||||
color: #FF0000;
|
||||
}
|
||||
|
||||
.red-box {
|
||||
width: 480rpx;
|
||||
height: 60rpx;
|
||||
margin: 20rpx 0 28rpx;
|
||||
background: rgba(253, 104, 93, .15);
|
||||
border-radius: 32px;
|
||||
font-size: 24rpx;
|
||||
color: #FD685D;
|
||||
|
||||
text {
|
||||
margin: 0 4rpx;
|
||||
padding: 4rpx 10rpx;
|
||||
background: #FF005E;
|
||||
color: #fff;
|
||||
font-size: 24rpx;
|
||||
opacity: 1;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.form-box {
|
||||
width: 620rpx;
|
||||
box-sizing: border-box;
|
||||
margin: 28rpx 0 64rpx;
|
||||
padding: 36rpx 39rpx;
|
||||
border: 2rpx solid #D6808D;
|
||||
box-shadow: 3px 3px 0 #D6808D;
|
||||
opacity: 1;
|
||||
border-radius: 40rpx;
|
||||
|
||||
.title {
|
||||
margin-bottom: 20rpx;
|
||||
font-weight: bold;
|
||||
font-size: 32rpx;
|
||||
line-height: 48rpx;
|
||||
color: #FF0000;
|
||||
}
|
||||
|
||||
.label {
|
||||
margin-bottom: 8rpx;
|
||||
color: #333333;
|
||||
font-size: 26rpx;
|
||||
font-weight: bold;
|
||||
line-height: 46rpx;
|
||||
}
|
||||
|
||||
.custom-input {
|
||||
height: 64rpx;
|
||||
line-height: 64rpx;
|
||||
box-sizing: border-box;
|
||||
margin-bottom: 16rpx;
|
||||
padding: 0 20rpx;
|
||||
border: 2rpx solid #E2E2E2;
|
||||
border-radius: 12rpx;
|
||||
color: #333333;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.submit-btn {
|
||||
margin-top: 40rpx;
|
||||
height: 64rpx;
|
||||
line-height: 64rpx;
|
||||
border-radius: 12rpx;
|
||||
background: #FF005E;
|
||||
color: #fff;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
// .address {
|
||||
// text {
|
||||
// width: 100%;
|
||||
// display: block;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
.people-box {
|
||||
width: 628rpx;
|
||||
height: 300rpx;
|
||||
background: rgba(253, 104, 93, 0.05);
|
||||
border-radius: 32rpx;
|
||||
margin-bottom: 58rpx;
|
||||
|
||||
.icon-horn {
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.title {
|
||||
margin: 18rpx 0 20rpx;
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
line-height: 40rpx;
|
||||
color: #FF005E;
|
||||
}
|
||||
|
||||
.list {
|
||||
.item {
|
||||
margin: 0 44rpx 4rpx;
|
||||
padding: 14rpx 30rpx;
|
||||
color: #FD685D;
|
||||
font-size: 24rpx;
|
||||
opacity: .5;
|
||||
}
|
||||
|
||||
.selected {
|
||||
background: rgba(253, 104, 93, 0.2);
|
||||
border-radius: 30px;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.grid-1 {
|
||||
width: 200rpx;
|
||||
}
|
||||
|
||||
.grid-2 {
|
||||
width: 182rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,129 @@
|
||||
<template>
|
||||
<view class="v4-project">
|
||||
<view class="top-box">
|
||||
<image :src="info.topImage"/>
|
||||
<view class="title tc bold">{{ info.name }}</view>
|
||||
</view>
|
||||
<view class="space"></view>
|
||||
|
||||
<view class="list-box">
|
||||
<view class="title">目录</view>
|
||||
<view class="item flex jc-between ai-center" v-for="(item,index) in info.contents" :key="index"
|
||||
@click="viewFile(item)">
|
||||
<view class="flex ai-center">
|
||||
<text class="index">{{ index + 1 }}</text>
|
||||
<text>{{ item.name }}</text>
|
||||
</view>
|
||||
|
||||
<image class="icon" :src="webUrl+'/20220903145836941399.png'"/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {investmentInfo} from "@/api/shop";
|
||||
|
||||
export default {
|
||||
name: "project",
|
||||
data() {
|
||||
return {
|
||||
webUrl: this.$VUE_APP_RESOURCES_URL,
|
||||
id: null,
|
||||
info: null
|
||||
}
|
||||
},
|
||||
onLoad(option) {
|
||||
this.id = option.id;
|
||||
this.init();
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
investmentInfo(this.id).then(({data}) => this.info = data);
|
||||
},
|
||||
|
||||
viewFile(item) {
|
||||
if (item.suffix === "pdf") {
|
||||
uni.downloadFile({
|
||||
url: item.attachment,
|
||||
success: res => {
|
||||
let filePath = res.tempFilePath;
|
||||
uni.openDocument({
|
||||
filePath
|
||||
})
|
||||
}
|
||||
})
|
||||
} else {
|
||||
uni.previewImage({
|
||||
urls: item.attachmentFiles
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.v4-project {
|
||||
min-height: 100vh;
|
||||
background: #fff;
|
||||
|
||||
.top-box {
|
||||
color: #333;
|
||||
font-size: 36rpx;
|
||||
|
||||
image {
|
||||
width: 750rpx;
|
||||
height: 416rpx;
|
||||
}
|
||||
|
||||
.title {
|
||||
padding: 30rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.space {
|
||||
height: 20rpx;
|
||||
background: #f9f9f9;
|
||||
}
|
||||
|
||||
.list-box {
|
||||
padding: 30rpx 32rpx;
|
||||
|
||||
.title {
|
||||
width: 68rpx;
|
||||
height: 48rpx;
|
||||
padding-bottom: 8rpx;
|
||||
border-bottom: 6rpx solid #FD574B;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
line-height: 48rpx;
|
||||
color: #FD574B;
|
||||
}
|
||||
|
||||
.item {
|
||||
padding: 40rpx 0;
|
||||
border-bottom: 2rpx solid #CDCDCD;;
|
||||
|
||||
|
||||
text {
|
||||
color: #333;
|
||||
font-size: 32rpx;
|
||||
line-height: 48rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.index {
|
||||
display: inline-block;
|
||||
width: 68rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.icon {
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,166 @@
|
||||
<template>
|
||||
<view class="v4-project-list">
|
||||
<view class="search-box flex jc-between ai-center">
|
||||
<input type="text" v-model="keyword" placeholder="请输入项目名称"/>
|
||||
<view class="btn flex jc-center ai-center" @click="search">
|
||||
<image :src="webUrl+'/20221019150834639123.png'"/>
|
||||
<text>搜索</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="item flex jc-between ai-center" v-for="(item,index) in list" :key="index" @click="getDetail(item.id)">
|
||||
<view class="flex ai-center">
|
||||
<image class="cover" :src="item.coverImage"/>
|
||||
<text>{{ item.name }}</text>
|
||||
</view>
|
||||
|
||||
<image class="icon" :src="webUrl+'/20220903145836941399.png'"/>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {investmentInfo, investmentList} from "@/api/shop";
|
||||
|
||||
export default {
|
||||
name: "projectList",
|
||||
data() {
|
||||
return {
|
||||
webUrl: this.$VUE_APP_RESOURCES_URL,
|
||||
page: 1, // 当前页
|
||||
keyword: "", // 搜索词
|
||||
pages: 0, // 总页数
|
||||
list: [],
|
||||
os: ""
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getOS();
|
||||
this.getData();
|
||||
},
|
||||
onReachBottom() {
|
||||
if (this.pages >= this.page) this.getData();
|
||||
},
|
||||
methods: {
|
||||
getOS() {
|
||||
uni.getSystemInfo({
|
||||
success: result => this.os = result.osName
|
||||
})
|
||||
},
|
||||
|
||||
search() {
|
||||
this.list = [];
|
||||
this.page = 1;
|
||||
this.getData();
|
||||
},
|
||||
|
||||
getData() {
|
||||
investmentList(this.page, this.keyword).then(({data}) => {
|
||||
this.pages = data.pages;
|
||||
this.page++;
|
||||
if (data.records.length > 0) {
|
||||
data.records.map(item => {
|
||||
this.list.push(item);
|
||||
})
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
getDetail(id) {
|
||||
investmentInfo(id).then(({data}) => {
|
||||
const file = data.contents[0];
|
||||
if (file.suffix === "pdf" && this.os === "android") {
|
||||
this.viewPdf(file.attachmentFiles[0])
|
||||
} else {
|
||||
let path = file.attachmentFiles[0];
|
||||
uni.navigateTo({
|
||||
url: "/pkg_common/views/pdf?path=" + encodeURI(path)
|
||||
})
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
viewPdf(url) {
|
||||
uni.downloadFile({
|
||||
url,//可以是后台传过来的路径
|
||||
success: res => {
|
||||
const filePath = res.tempFilePath
|
||||
uni.openDocument({
|
||||
filePath,
|
||||
fileType: "pdf",
|
||||
success: result => {
|
||||
//成功
|
||||
},
|
||||
fail: err => {
|
||||
uni.showModal({
|
||||
title: "openDocument fail",
|
||||
content: JSON.stringify(err)
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
fail: err => {
|
||||
uni.showModal({
|
||||
title: "downloadFile fail",
|
||||
content: JSON.stringify(err)
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.v4-project-list {
|
||||
.search-box {
|
||||
height: 80rpx;
|
||||
margin: 40rpx 32rpx;
|
||||
box-sizing: border-box;
|
||||
padding: 0 16rpx 0 32rpx;
|
||||
background: #fff;
|
||||
border-radius: 40rpx;
|
||||
font-size: 24rpx;
|
||||
|
||||
image {
|
||||
width: 28rpx;
|
||||
height: 28rpx;
|
||||
margin-right: 4rpx;
|
||||
}
|
||||
|
||||
.btn {
|
||||
width: 128rpx;
|
||||
height: 54rpx;
|
||||
background: #FD574B;
|
||||
border-radius: 28rpx;
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
.item {
|
||||
height: 160rpx;
|
||||
box-sizing: border-box;
|
||||
margin: 40rpx 32rpx;
|
||||
padding: 0 16rpx 0 28rpx;
|
||||
background: #fff;
|
||||
box-shadow: 0 6rpx 20rpx rgba(0, 0, 0, 0.16);
|
||||
border-radius: 8rpx;
|
||||
|
||||
.cover {
|
||||
width: 160rpx;
|
||||
height: 88rpx;
|
||||
margin-right: 40rpx;
|
||||
}
|
||||
|
||||
text {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.icon {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,104 @@
|
||||
<template>
|
||||
<view class="page-v4 flex flex-wrap">
|
||||
|
||||
<view class="item" v-for="item in 9" :key="item">
|
||||
<view class="img-box">
|
||||
<image class="main-img" :src="webUrl+'/20220214125726718023.png'" mode="scaleToFill"></image>
|
||||
<view class="label flex ai-center">
|
||||
<image class="icon-live" :src="webUrl+'/20220218221956204228.png'" mode="scaleToFill"></image>
|
||||
<text>文化展示</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="info flex ai-center">
|
||||
<image class="logo" :src="webUrl+'/20220105121325790975.png'" mode="scaleToFill"></image>
|
||||
<view>
|
||||
<view class="name">香道滇旗舰店</view>
|
||||
<view class="sub">冬季上新买二送一!</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
webUrl: this.$VUE_APP_RESOURCES_URL
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.page-v4 {
|
||||
padding: 0 32rpx 24rpx;
|
||||
}
|
||||
|
||||
.main-img {
|
||||
width: 332rpx;
|
||||
height: 360rpx;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.icon-live {
|
||||
width: 26rpx;
|
||||
height: 26rpx;
|
||||
margin-right: 4rpx;
|
||||
}
|
||||
|
||||
.logo {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
border-radius: 50%;
|
||||
margin-right: 8rpx;
|
||||
}
|
||||
|
||||
.item {
|
||||
width: 332rpx;
|
||||
margin-top: 24rpx;
|
||||
border-radius: 8px 8px 0 0;
|
||||
background: #fff;
|
||||
|
||||
.name {
|
||||
font-size: 24rpx;
|
||||
font-weight: bold;
|
||||
line-height: 34rpx;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.sub {
|
||||
font-size: 20rpx;
|
||||
font-weight: bold;
|
||||
line-height: 30rpx;
|
||||
color: #999999;
|
||||
}
|
||||
}
|
||||
|
||||
.item:nth-child(2n) {
|
||||
margin-left: 22rpx;
|
||||
}
|
||||
|
||||
.info {
|
||||
padding: 8rpx 16rpx 18rpx;
|
||||
}
|
||||
|
||||
.img-box{
|
||||
position: relative;
|
||||
.label {
|
||||
position: absolute;
|
||||
top: 14rpx;
|
||||
left: 16rpx;
|
||||
padding: 4rpx 14rpx 4rpx 10rpx;
|
||||
border-radius: 20px;
|
||||
font-size: 22rpx;
|
||||
line-height: 1;
|
||||
color: #FFFFFF;
|
||||
background: rgba(0,0,0,.6);
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,117 @@
|
||||
<template>
|
||||
<view class="logs-view">
|
||||
<view class="btn-box">
|
||||
<button type="default" plain size="mini">抽奖日期</button>
|
||||
<button type="default" plain size="mini">抽奖结果</button>
|
||||
</view>
|
||||
|
||||
<view class="list-box">
|
||||
<view class="item flex jc-between ai-center" v-for="item in list">
|
||||
<view class="flex">
|
||||
<text class="date">{{item.drawTime}}</text>
|
||||
<text class="goods one-t">{{item.prizeName}}</text>
|
||||
</view>
|
||||
|
||||
<image class="btn flex-0" :src="webUrl+'/20220611142551342281.png'" @click="goReceive(item.id)"
|
||||
v-if="item.status==1 && item.isHit==1"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
getLotteryRecordsMy
|
||||
} from "@/api/luck.js";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
webUrl: this.$VUE_APP_RESOURCES_URL,
|
||||
lotteryId: null,
|
||||
list: [],
|
||||
page: 1
|
||||
}
|
||||
},
|
||||
onLoad(option) {
|
||||
this.lotteryId = option.id;
|
||||
},
|
||||
onShow() {
|
||||
this.list = [];
|
||||
this.fetchList();
|
||||
},
|
||||
onReachBottom() {
|
||||
this.page++;
|
||||
this.fetchList();
|
||||
},
|
||||
methods: {
|
||||
fetchList() {
|
||||
getLotteryRecordsMy(this.lotteryId, this.page).then(res => {
|
||||
for (let i = 0; i < res.data.records.length; i++) {
|
||||
this.list.push(res.data.records[i])
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
goReceive(id) {
|
||||
uni.navigateTo({
|
||||
url: "receive?id=" + id
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.logs-view {
|
||||
position: relative;
|
||||
height: 100vh;
|
||||
background: linear-gradient(180deg, #FFD884 0%, #FF5307 100%);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.btn-box {
|
||||
margin-top: 54rpx;
|
||||
|
||||
button {
|
||||
outline: none;
|
||||
margin: 0 88rpx;
|
||||
border: none;
|
||||
border-radius: 30rpx;
|
||||
background: linear-gradient(180deg, #ffcd1e 0%, #ff8a18 100%);
|
||||
color: #fff;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.list-box {
|
||||
height: 75vh;
|
||||
margin-top: 20rpx;
|
||||
padding: 32rpx;
|
||||
overflow-y: auto;
|
||||
|
||||
.item {
|
||||
height: 60rpx;
|
||||
margin-bottom: 16rpx;
|
||||
padding: 0 46rpx;
|
||||
border-radius: 30rpx;
|
||||
background: rgba(255, 255, 255, .4);
|
||||
font-size: 24rpx;
|
||||
|
||||
.date {
|
||||
display: inline-block;
|
||||
width: 350rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.goods {
|
||||
width: 190rpx;
|
||||
color: #FF1200;
|
||||
}
|
||||
|
||||
.btn {
|
||||
width: 80rpx;
|
||||
height: 38rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,379 @@
|
||||
<template>
|
||||
<view class="luck-view">
|
||||
<image class="bg-luck" :src="webUrl+'/20220210153759193846.png'" mode="scaleToFill"></image>
|
||||
<image class="btn-log" :src="webUrl+'/20220210142514268256.png'" mode="scaleToFill" @click="goLogs"></image>
|
||||
<image class="dialog" :src="webUrl+'/20220210142530967881.png'" mode="scaleToFill" v-if="newRecords.length>0">
|
||||
</image>
|
||||
<view class="dialog" v-if="newRecords.length>0">
|
||||
<swiper :indicator-dots="false" :autoplay="true" :interval="5000" :duration="1000" circular>
|
||||
<swiper-item v-for="item in newRecords" :key="item">
|
||||
<view class="acea-row row-middle">
|
||||
<image class="avatar" :src="item.avatar" mode="scaleToFill"></image>
|
||||
<text>恭喜{{ item.username }}获得{{ item.prizeName }}</text>
|
||||
</view>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
</view>
|
||||
|
||||
<!-- 大转盘抽奖 -->
|
||||
<view class="wheel-box" v-show="!isDialog">
|
||||
</view>
|
||||
|
||||
<image class="btn-tip" :src="webUrl+'/20220210142525648150.png'" mode="scaleToFill" v-if="lotteryInfo"></image>
|
||||
<view class="btn-tip acea-row row-center-wrapper" v-if="lotteryInfo">
|
||||
<view>剩余
|
||||
<text>{{ lotteryInfo.lotteryUserInfo.dayLimit }}</text>
|
||||
次抽奖机会
|
||||
</view>
|
||||
<!-- <view>剩余<text>{{parseInt(lotteryInfo.lotteryUserInfo.lotteryPoints/lotteryInfo.singleCost)}}</text>次抽奖机会</view> -->
|
||||
</view>
|
||||
|
||||
<view class="tip-box" v-html="lotteryInfo.description" v-if="lotteryInfo">
|
||||
<!-- <view>1.每天有1次幸运大转盘的抽奖机会</view>
|
||||
<view>2.每次抽奖需要消耗{{lotteryInfo.singleCost}}幸运币。</view>
|
||||
<view>3.抽中商品后可去个人中心页面查看订单详情。</view> -->
|
||||
</view>
|
||||
<image class="btn-role" :src="webUrl+'/20220210142520109834.png'" mode="scaleToFill"></image>
|
||||
|
||||
<cover-view class="result-mark" v-if="isDialog">
|
||||
<cover-view class="result-dialog flex flex-col ai-center">
|
||||
<cover-image class="icon-close" :src="webUrl+'/20220610111928963051.png'" mode="scaleToFill"
|
||||
@click="isDialog=false"/>
|
||||
<cover-view class="title">恭喜您,中奖啦!</cover-view>
|
||||
<cover-image class="cover" :src="result.imgs[0].src" mode="scaleToFill"/>
|
||||
<cover-view class="name">获得的是{{ result.fonts[0].text }}</cover-view>
|
||||
<button class="btn-fetch" type="default" @click="goReceive">去领取</button>
|
||||
<button class="btn-close" type="default" @click="isDialog=false">关闭</button>
|
||||
</cover-view>
|
||||
</cover-view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {draw, getLotteryInfo, getLotteryRecordsNew} from "@/api/luck.js";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
webUrl: this.$VUE_APP_RESOURCES_URL,
|
||||
blocks: [],
|
||||
buttons: [],
|
||||
prizes: [],
|
||||
defaultConfig: {
|
||||
stopRange: 0.5
|
||||
},
|
||||
lotteryId: null,
|
||||
newRecords: [],
|
||||
lotteryInfo: null,
|
||||
isDialog: false,
|
||||
result: {},
|
||||
lotteryRecordId: null, //抽奖记录ID
|
||||
hitIndex: 0,
|
||||
isWait: false
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.getLuck();
|
||||
this.blocks = [{
|
||||
imgs: [{
|
||||
src: this.webUrl + '/20220210142536583482.png',
|
||||
width: '100%',
|
||||
height: '100%'
|
||||
}]
|
||||
}]
|
||||
this.buttons = [{
|
||||
radius: '50%',
|
||||
imgs: [{
|
||||
src: this.webUrl + '/20220210142504244580.png',
|
||||
width: '177rpx',
|
||||
top: '-65%'
|
||||
}]
|
||||
}]
|
||||
|
||||
},
|
||||
methods: {
|
||||
// 初始化
|
||||
getLuck() {
|
||||
getLotteryInfo().then(({
|
||||
data
|
||||
}) => {
|
||||
this.lotteryId = data.id;
|
||||
this.lotteryInfo = data;
|
||||
|
||||
// 处理奖品数据
|
||||
let len = this.lotteryInfo.prizeList.length;
|
||||
let temp;
|
||||
for (let i = 0; i < len; i++) {
|
||||
temp = {
|
||||
imgs: [{
|
||||
src: this.lotteryInfo.prizeList[i].image,
|
||||
width: "80rpx",
|
||||
height: "80rpx",
|
||||
top: "85%"
|
||||
}],
|
||||
fonts: [{
|
||||
text: this.lotteryInfo.prizeList[i].name,
|
||||
top: '50%',
|
||||
fontSize: '28rpx'
|
||||
}]
|
||||
}
|
||||
|
||||
this.$set(this.prizes, i, temp)
|
||||
}
|
||||
|
||||
getLotteryRecordsNew(this.lotteryId).then(({
|
||||
data
|
||||
}) => this.newRecords = data);
|
||||
})
|
||||
},
|
||||
|
||||
// 跳转奖品记录
|
||||
goLogs() {
|
||||
this.$yrouter.push('/v4/views/luck/logs?id=' + this.lotteryId);
|
||||
},
|
||||
// 点击抽奖按钮触发回调
|
||||
startCallBack() {
|
||||
let that = this;
|
||||
if (this.isWait) return;
|
||||
this.isWait = true;
|
||||
|
||||
if (this.lotteryId == null) {
|
||||
uni.showToast({
|
||||
title: "无抽奖活动",
|
||||
icon: 'none'
|
||||
})
|
||||
return;
|
||||
}
|
||||
draw(this.lotteryId).then(res => {
|
||||
if (res.success) {
|
||||
that.lotteryRecordId = res.data.id;
|
||||
let surplus = that.lotteryInfo.lotteryUserInfo.dayLimit - 1;
|
||||
if (surplus > -1) {
|
||||
that.$set(that.lotteryInfo.lotteryUserInfo, "dayLimit", surplus)
|
||||
}
|
||||
|
||||
for (let i = 0, len = that.lotteryInfo.prizeList.length; i < len; i++) {
|
||||
if (res.data.prizeId == that.lotteryInfo.prizeList[i].id) {
|
||||
that.hitIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 先开始旋转
|
||||
that.$refs.myLucky.play()
|
||||
that.isHit = res.data.isHit;
|
||||
// 使用定时器来模拟请求接口
|
||||
setTimeout(() => {
|
||||
// 调用stop停止旋转并传递中奖索引
|
||||
if (res.data.prizeId == null) that.hitIndex = -1;
|
||||
that.$refs.myLucky.stop(that.hitIndex)
|
||||
}, 3000)
|
||||
} else {
|
||||
that.isWait = false;
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: "none",
|
||||
duration: 3000
|
||||
});
|
||||
}
|
||||
}).catch(err => {
|
||||
that.isWait = false;
|
||||
uni.showToast({
|
||||
title: err.msg,
|
||||
icon: "none",
|
||||
duration: 3000
|
||||
});
|
||||
})
|
||||
|
||||
},
|
||||
// 抽奖结束触发回调
|
||||
endCallBack(prize) {
|
||||
// 奖品详情
|
||||
console.log(prize)
|
||||
this.result = prize;
|
||||
this.isWait = false;
|
||||
|
||||
if (this.lotteryInfo.prizeList[this.hitIndex].name == "谢谢参与") {
|
||||
uni.showToast({
|
||||
title: "别灰心,好运一定会来",
|
||||
icon: "none",
|
||||
duration: 3000
|
||||
});
|
||||
return
|
||||
}
|
||||
this.isDialog = true;
|
||||
},
|
||||
|
||||
goReceive() {
|
||||
this.isDialog = false;
|
||||
uni.navigateTo({
|
||||
url: "receive?id=" + this.lotteryRecordId
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
image {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.luck-view {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.bg-luck {
|
||||
width: 750rpx;
|
||||
height: 1523rpx;
|
||||
}
|
||||
|
||||
.btn-log {
|
||||
width: 109rpx;
|
||||
height: 49rpx;
|
||||
position: absolute;
|
||||
top: 18rpx;
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.dialog {
|
||||
width: 521rpx;
|
||||
height: 111rpx;
|
||||
position: absolute;
|
||||
top: 240rpx;
|
||||
left: 114.5rpx;
|
||||
font-size: 24rpx;
|
||||
color: #fff;
|
||||
|
||||
.acea-row {
|
||||
margin-top: 27rpx;
|
||||
margin-left: 22rpx;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 36rpx;
|
||||
height: 36rpx;
|
||||
margin-right: 20rpx;
|
||||
background: #FFBEBE;
|
||||
border-radius: 50%;
|
||||
}
|
||||
}
|
||||
|
||||
.wheel-box {
|
||||
position: absolute;
|
||||
top: 352rpx;
|
||||
left: 65rpx;
|
||||
}
|
||||
|
||||
.btn-tip {
|
||||
width: 372rpx;
|
||||
height: 61rpx;
|
||||
position: absolute;
|
||||
top: 1014rpx;
|
||||
left: 189rpx;
|
||||
font-size: 24rpx;
|
||||
color: #fff;
|
||||
|
||||
text {
|
||||
font-size: 40rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.tip-box {
|
||||
width: 670rpx;
|
||||
height: 290rpx;
|
||||
position: absolute;
|
||||
bottom: 90rpx;
|
||||
left: 40rpx;
|
||||
box-sizing: border-box;
|
||||
padding: 46rpx 30rpx 30rpx;
|
||||
border: 4rpx solid #E69F42;
|
||||
border-radius: 32rpx;
|
||||
background: #fff;
|
||||
font-size: 30rpx;
|
||||
line-height: 1.5;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.btn-role {
|
||||
width: 156rpx;
|
||||
height: 60rpx;
|
||||
position: absolute;
|
||||
bottom: 363rpx;
|
||||
left: 92rpx;
|
||||
}
|
||||
|
||||
.result-mark {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background: rgba(51, 51, 51, 0.39);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.result-dialog {
|
||||
position: absolute;
|
||||
top: 300rpx;
|
||||
left: 50%;
|
||||
transform: translate(-50%, 0);
|
||||
width: 458rpx;
|
||||
height: 560rpx;
|
||||
border-radius: 20rpx;
|
||||
background: #FFF5DB;
|
||||
|
||||
.icon-close {
|
||||
position: absolute;
|
||||
top: 20rpx;
|
||||
right: 26rpx;
|
||||
width: 26rpx;
|
||||
height: 26rpx;
|
||||
}
|
||||
|
||||
.title {
|
||||
margin-top: 40rpx;
|
||||
font-size: 34rpx;
|
||||
font-weight: bold;
|
||||
line-height: 50rpx;
|
||||
color: #FF0000;
|
||||
}
|
||||
|
||||
.cover {
|
||||
width: 240rpx;
|
||||
height: 240rpx;
|
||||
vertical-align: middle;
|
||||
margin: 15rpx 0;
|
||||
border-radius: 15rpx;
|
||||
}
|
||||
|
||||
.name {
|
||||
font-size: 24rpx;
|
||||
line-height: 34rpx;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
button::after {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.btn-fetch {
|
||||
width: 176rpx;
|
||||
height: 60rpx;
|
||||
line-height: 60rpx;
|
||||
margin-top: 28rpx;
|
||||
border-radius: 30rpx;
|
||||
background: #FD685D;
|
||||
color: #fff;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.btn-close {
|
||||
height: 34rpx;
|
||||
line-height: 34rpx;
|
||||
margin-top: 12rpx;
|
||||
font-size: 24rpx;
|
||||
color: #D6BA70;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,159 @@
|
||||
<template>
|
||||
<view class="receive-view">
|
||||
<view class="item flex ai-center" :class="{'active':selectIndex===index}" v-for="(item,index) in list"
|
||||
@click="tapItem(index)">
|
||||
<image class="select" :src="webUrl+'/20220613104953149068.png'" mode="scaleToFill" v-if="selectIndex===index" />
|
||||
|
||||
<view class="content">
|
||||
<view class="base flex ai-center">
|
||||
<view>{{item.realName}}</view>
|
||||
<view class="phone">{{item.phone}}</view>
|
||||
</view>
|
||||
|
||||
<view class="address more-t">{{item.province}}{{item.city}}{{item.district}}{{item.detail}}</view>
|
||||
</view>
|
||||
|
||||
<image class="default" :src="webUrl+'/20220613104939432841.png'" mode="scaleToFill" v-if="item.isDefault===1" />
|
||||
</view>
|
||||
|
||||
<button class="btn-receive" type="default" @click="receive">确认领取</button>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
getAddressList
|
||||
} from "@/api/user";
|
||||
import {
|
||||
takePrize
|
||||
} from "@/api/luck";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
webUrl: this.$VUE_APP_RESOURCES_URL,
|
||||
id: null, //领奖记录ID
|
||||
list: [], //收货地址列表
|
||||
selectIndex: 0
|
||||
}
|
||||
},
|
||||
onLoad(option) {
|
||||
this.id = option.id;
|
||||
this.fetchList();
|
||||
},
|
||||
methods: {
|
||||
fetchList() {
|
||||
getAddressList({
|
||||
page: 1,
|
||||
limit: 999
|
||||
}).then(res => {
|
||||
if (res.success) {
|
||||
this.list = res.data;
|
||||
if (this.list.length) {
|
||||
for (let i = 0; i < this.list.length; i++) {
|
||||
if (this.list[i].isDefault === 1) this.selectIndex = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
tapItem(index) {
|
||||
this.selectIndex = index;
|
||||
},
|
||||
|
||||
receive() {
|
||||
takePrize(this.id, this.list[this.selectIndex].id).then(res => {
|
||||
uni.showToast({
|
||||
icon: "none",
|
||||
title: res.data,
|
||||
success: () => {
|
||||
if (res.success) {
|
||||
setTimeout(() => {
|
||||
uni.navigateBack();
|
||||
}, 3000)
|
||||
}
|
||||
}
|
||||
})
|
||||
}).catch(err => {
|
||||
uni.showToast({
|
||||
icon: "error",
|
||||
title: err.msg
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.receive-view {
|
||||
padding: 40rpx;
|
||||
|
||||
.active {
|
||||
box-shadow: 0px 6px 12px rgba(191, 189, 197, 0.6);
|
||||
}
|
||||
|
||||
.item {
|
||||
position: relative;
|
||||
height: 172rpx;
|
||||
margin-bottom: 32rpx;
|
||||
padding: 24rpx 20rpx 28rpx 0;
|
||||
background: #fff;
|
||||
border-radius: 12rpx;
|
||||
|
||||
.content {
|
||||
margin-left: 24rpx;
|
||||
|
||||
.base {
|
||||
color: #080F1A;
|
||||
font-size: 28rpx;
|
||||
line-height: 40rpx;
|
||||
font-weight: bold;
|
||||
|
||||
.phone {
|
||||
margin-left: 18rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.address {
|
||||
width: 100%;
|
||||
height: 70rpx;
|
||||
margin-top: 12rpx;
|
||||
font-size: 24rpx;
|
||||
line-height: 40rpx;
|
||||
color: #999999;
|
||||
}
|
||||
}
|
||||
|
||||
.select {
|
||||
width: 28rpx;
|
||||
height: 28rpx;
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
|
||||
.default {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: 72rpx;
|
||||
height: 36rpx;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.btn-receive {
|
||||
position: fixed;
|
||||
bottom: 80rpx;
|
||||
left: 0;
|
||||
width: 686rpx;
|
||||
height: 80rpx;
|
||||
margin: 0 32rpx;
|
||||
border-radius: 40rpx;
|
||||
box-shadow: 0px 6px 12px rgba(0, 0, 0, 0.16);
|
||||
background: #FF564A;
|
||||
color: #fff;
|
||||
font-size: 30rpx;
|
||||
line-height: 80rpx;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,249 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="first-line flex jc-between ai-center">
|
||||
<view class="date-box flex">
|
||||
<image class="icon-date" :src="webUrl+'/20220214125601027724.png'" mode="scaleToFill"></image>
|
||||
<view class="day"><text>{{date}}</text>DAY</view>
|
||||
<view class="month">{{month}}月</view>
|
||||
</view>
|
||||
<view class="end-time flex">
|
||||
<text>倒计时</text>
|
||||
<count-down :isDay="false" isSecond :dayText="false" :hourText="':'" :minuteText="':'" :secondText="false"
|
||||
:datatime="datatime"></count-down>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="list flex flex-wrap" v-if="list.length">
|
||||
<view class="item" v-for="item in list" :key="item" @click="goGoodsConByProductID(item)">
|
||||
<view class="img-box">
|
||||
<image class="main" :src="item.image" mode="scaleToFill"></image>
|
||||
<image class="label" :src="webUrl+'/20220525103739004011.png'" mode="scaleToFill"></image>
|
||||
</view>
|
||||
<view class="content">
|
||||
<view class="title one-t">{{item.title}}</view>
|
||||
<view class="price flex ai-center">
|
||||
<!-- <image class="label-vip" :src="webUrl+'/20221118104357701129.png'" mode="scaleToFill"></image> -->
|
||||
<text>¥{{item.price}}</text>
|
||||
<text class="del" v-if="item.productPrice">¥{{item.productPrice}}</text>
|
||||
</view>
|
||||
<view class="over-line flex ai-center">
|
||||
<image class="icon-fire" :src="webUrl+'/20221118092713277343.png'" mode="scaleToFill"></image>
|
||||
<text>{{item.sales}}人已购买</text>
|
||||
</view>
|
||||
<!-- <view class="cart-box flex ai-center jc-between">{{item.merName}}</view> -->
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="v4-nodata" v-else>
|
||||
<image src="@/static/images/img_nodata.png" mode="scaleToFill" />
|
||||
<view class="text">暂无数据</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
getDailyGoodsList
|
||||
} from "@/api/goods";
|
||||
import CountDown from "@/components/CountDown";
|
||||
export default {
|
||||
components: {
|
||||
CountDown
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
webUrl: this.$VUE_APP_RESOURCES_URL,
|
||||
page: 1,
|
||||
list: [],
|
||||
endReach: false,
|
||||
month: 0, // 每日特价:月
|
||||
date: 0, // 每日特价:日
|
||||
datatime: 0, // 倒计时
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
let today = new Date();
|
||||
this.month = today.getMonth() + 1;
|
||||
this.date = today.getDate();
|
||||
|
||||
today.setHours(23);
|
||||
today.setMinutes(59);
|
||||
today.setSeconds(59);
|
||||
|
||||
this.datatime = today.getTime() / 1000;
|
||||
|
||||
this.fetchList(this.page);
|
||||
},
|
||||
onReachBottom() {
|
||||
if (this.endReach) return;
|
||||
this.page++;
|
||||
this.fetchList(this.page);
|
||||
},
|
||||
methods: {
|
||||
goGoodsConByProductID(item) {
|
||||
this.$yrouter.push({
|
||||
path: '/pages/shop/GoodsCon/index',
|
||||
query: {
|
||||
id: item.productId,
|
||||
activityId:item.id,
|
||||
from:"day"
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
fetchList(page) {
|
||||
getDailyGoodsList(page, 10).then(({
|
||||
data
|
||||
}) => {
|
||||
if (data.records.length > 0) {
|
||||
data.records.map(item => this.list.push(item));
|
||||
} else {
|
||||
this.endReach = true;
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.first-line {
|
||||
margin: 16rpx 32rpx 0;
|
||||
}
|
||||
|
||||
.end-time {
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
line-height: 40rpx;
|
||||
color: #FD685D;
|
||||
}
|
||||
|
||||
.date-box {
|
||||
align-items: center;
|
||||
padding: 8rpx;
|
||||
background: #fff;
|
||||
border-radius: 8px;
|
||||
|
||||
.icon-date {
|
||||
width: 40rpx;
|
||||
height: 40rpx;
|
||||
}
|
||||
|
||||
.day {
|
||||
color: #494949;
|
||||
font-size: 40rpx;
|
||||
font-weight: bold;
|
||||
|
||||
text {
|
||||
color: #FF1200;
|
||||
}
|
||||
}
|
||||
|
||||
.month {
|
||||
height: 32rpx;
|
||||
margin-left: 12rpx;
|
||||
padding-left: 6rpx;
|
||||
border-left: 2rpx solid #DDDDDD;
|
||||
color: #999999;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.list {
|
||||
margin: 24rpx 32rpx 0;
|
||||
|
||||
.item:nth-child(2n) {
|
||||
margin-left: 22rpx;
|
||||
}
|
||||
|
||||
.item {
|
||||
width: 332rpx;
|
||||
margin-bottom: 24rpx;
|
||||
border-radius: 8rpx;
|
||||
background: #fff;
|
||||
|
||||
.img-box {
|
||||
position: relative;
|
||||
|
||||
.main {
|
||||
width: 332rpx;
|
||||
height: 332rpx;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.label {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 94rpx;
|
||||
height: 42rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
.label-vip {
|
||||
width: 40rpx;
|
||||
height: 24rpx;
|
||||
margin-right: 6rpx;
|
||||
}
|
||||
|
||||
.icon-fire {
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
}
|
||||
|
||||
.icon-cart {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
}
|
||||
|
||||
.title {
|
||||
margin: 8rpx 4rpx 0 10rpx;
|
||||
font-size: 26rpx;
|
||||
font-weight: bold;
|
||||
line-height: 36rpx;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.price {
|
||||
padding: 4rpx 10rpx 10rpx;
|
||||
font-size: 26rpx;
|
||||
font-weight: bold;
|
||||
line-height: 38rpx;
|
||||
color: #ED0F0F;
|
||||
|
||||
.del {
|
||||
margin-left: 16rpx;
|
||||
text-decoration: line-through;
|
||||
font-size: 20rpx;
|
||||
line-height: 30rpx;
|
||||
font-weight: normal;
|
||||
color: #A5A5A5;
|
||||
}
|
||||
}
|
||||
|
||||
.over-line {
|
||||
margin: 0 12rpx 20rpx;
|
||||
color: #333;
|
||||
font-size: 22rpx;
|
||||
line-height: 32rpx;
|
||||
|
||||
.icon-fire {
|
||||
width: 24rpx;
|
||||
height: 24rpx;
|
||||
margin-right: 8rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.cart-box {
|
||||
padding: 6rpx 10rpx 12rpx;
|
||||
border-top: 1rpx solid #EFEFEF;
|
||||
font-size: 22rpx;
|
||||
line-height: 32rpx;
|
||||
color: #333333;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,178 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="list flex flex-wrap" v-if="list.length">
|
||||
<view class="item" v-for="item in list" :key="item" @click="goGoodsConByProductID(item)">
|
||||
<view class="img-box">
|
||||
<image class="main" :src="item.image" mode="scaleToFill"></image>
|
||||
</view>
|
||||
<view class="content">
|
||||
<view class="title one-t">{{item.title}}</view>
|
||||
<view class="price flex ai-center">
|
||||
<image class="label-vip" :src="webUrl+'/20221118104357701129.png'" mode="scaleToFill"></image>
|
||||
<text>¥{{item.price}}</text>
|
||||
</view>
|
||||
<view class="over-line flex jc-between ai-center">
|
||||
<text>{{item.stopTime.substring(0,10)}}结束</text>
|
||||
<view>
|
||||
<text>还剩</text>
|
||||
<text class="red">{{item.surplus}}天</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="cart-box flex ai-center jc-between">
|
||||
<view class="flex ai-center">
|
||||
<image class="icon-fire" :src="webUrl+'/20220214125601027724.png'" mode="scaleToFill"></image>
|
||||
<text>{{item.postTime.substring(0,10)}}发货</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="v4-nodata" v-else>
|
||||
<image src="@/static/images/img_nodata.png" mode="scaleToFill" />
|
||||
<view class="text">暂无数据</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
getPreSaleList
|
||||
} from "@/api/goods";
|
||||
import {
|
||||
formatDateTime,
|
||||
diffDay
|
||||
} from "@/utils/index";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
webUrl: this.$VUE_APP_RESOURCES_URL,
|
||||
page: 1,
|
||||
list: [],
|
||||
endReach: false,
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.fetchList(this.page);
|
||||
},
|
||||
onReachBottom() {
|
||||
if (this.endReach) return;
|
||||
this.page++;
|
||||
this.fetchList(this.page);
|
||||
},
|
||||
methods: {
|
||||
goGoodsConByProductID(item) {
|
||||
this.$yrouter.push({
|
||||
path: '/pages/shop/GoodsCon/index',
|
||||
query: {
|
||||
id: item.productId,
|
||||
activityId: item.id,
|
||||
from: "pre"
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
fetchList(page) {
|
||||
getPreSaleList(page, 10).then(({
|
||||
data
|
||||
}) => {
|
||||
if (data.records.length > 0) {
|
||||
data.records.map(item => {
|
||||
var now = new Date().getTime();
|
||||
var nowStr = formatDateTime(now, 'yyyy-MM-dd');
|
||||
item.surplus = diffDay(nowStr, item.stopTime.substring(0, 10))
|
||||
this.list.push(item)
|
||||
});
|
||||
} else {
|
||||
this.endReach = true;
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.list {
|
||||
margin: 24rpx 32rpx 0;
|
||||
|
||||
.item:nth-child(2n) {
|
||||
margin-left: 22rpx;
|
||||
}
|
||||
|
||||
.item {
|
||||
width: 332rpx;
|
||||
margin-bottom: 24rpx;
|
||||
border-radius: 8rpx;
|
||||
background: #fff;
|
||||
|
||||
.img-box {
|
||||
position: relative;
|
||||
|
||||
.main {
|
||||
width: 332rpx;
|
||||
height: 332rpx;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
.label-vip {
|
||||
width: 40rpx;
|
||||
height: 24rpx;
|
||||
margin-right: 6rpx;
|
||||
}
|
||||
|
||||
.icon-fire {
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
}
|
||||
|
||||
.icon-cart {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
}
|
||||
|
||||
.title {
|
||||
margin: 8rpx 4rpx 0 10rpx;
|
||||
font-size: 26rpx;
|
||||
font-weight: bold;
|
||||
line-height: 36rpx;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.price {
|
||||
padding: 4rpx 10rpx 10rpx;
|
||||
font-size: 26rpx;
|
||||
font-weight: bold;
|
||||
line-height: 38rpx;
|
||||
color: #ED0F0F;
|
||||
}
|
||||
|
||||
.over-line {
|
||||
margin: 0 12rpx 8rpx;
|
||||
color: #999;
|
||||
font-size: 22rpx;
|
||||
line-height: 32rpx;
|
||||
|
||||
.red {
|
||||
color: #ED0F0F;
|
||||
}
|
||||
}
|
||||
|
||||
.cart-box {
|
||||
padding: 8rpx 16rpx 14rpx 18rpx;
|
||||
border-top: 1rpx solid #EFEFEF;
|
||||
|
||||
text {
|
||||
margin-left: 2rpx;
|
||||
font-size: 24rpx;
|
||||
font-weight: bold;
|
||||
line-height: 36rpx;
|
||||
color: #FD685D;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,349 @@
|
||||
<template>
|
||||
<view class="page-seckill">
|
||||
<view class="next-box" v-if="nextList.length>0">
|
||||
<view class="info flex ai-center"><text>下场秒杀时间:</text><text class="red">{{seckillTime[seckillTimeIndex+1].time}}</text></view>
|
||||
<view class="img-box flex">
|
||||
<image :src="item.image" mode="scaleToFill" v-for="item in nextList" :key="item"></image>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="header acea-row">
|
||||
<view>
|
||||
<view class="title">限时秒杀</view>
|
||||
<view class="sub-title">尖货限时抢</view>
|
||||
</view>
|
||||
<view class="count-box">
|
||||
<count-down :isDay="false" isSecond :dayText="false" :hourText="':'" :minuteText="':'" :secondText="false"
|
||||
:datatime="seckillTime[seckillTimeIndex].stop"></count-down>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="list flex flex-wrap">
|
||||
<view class="item" v-for="item in list" :key="item" @click="goGoodsConByProductID(item)">
|
||||
<view class="img-box">
|
||||
<image class="main" :src="item.image" mode="scaleToFill"></image>
|
||||
<!-- <image class="label" :src="webUrl+'/20220525103739004011.png'" mode="scaleToFill"></image> -->
|
||||
</view>
|
||||
<view class="content">
|
||||
<view class="title more-t">{{item.productName}}</view>
|
||||
<view class="price flex ai-center">
|
||||
<!-- <image class="label-vip" :src="webUrl+'/20221118104357701129.png'" mode="scaleToFill"></image> -->
|
||||
<text>¥{{item.price}}</text>
|
||||
<text class="del">¥{{item.otPrice}}</text>
|
||||
</view>
|
||||
<view class="cart-box flex ai-center jc-between">
|
||||
<view class="flex ai-center">
|
||||
<image class="icon-fire" :src="webUrl+'/20220214125642215597.png'" mode="scaleToFill"></image>
|
||||
<text>{{item.sales}}人已购买</text>
|
||||
</view>
|
||||
<image class="icon-cart" :src="webUrl+'/20220214125543267695.png'" mode="scaleToFill"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="header acea-row" v-if="nextList.length>0">
|
||||
<view>
|
||||
<view class="title">下场预告商品</view>
|
||||
<view class="sub-title">下一场{{seckillTime[seckillTimeIndex+1].time}}开始</view>
|
||||
</view>
|
||||
<view class="count-box">
|
||||
<count-down :isDay="false" isSecond :dayText="false" :hourText="':'" :minuteText="':'" :secondText="false"
|
||||
:datatime="seckillTime[seckillTimeIndex+1].start"></count-down>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="list flex flex-wrap" v-if="nextList.length>0">
|
||||
<view class="item" v-for="item in nextList" :key="item" @click="goGoodsConByProductID(item)">
|
||||
<view class="img-box">
|
||||
<image class="main" :src="item.image" mode="scaleToFill"></image>
|
||||
<!-- <image class="label" :src="webUrl+'/20220219171325371623.png'" mode="scaleToFill"></image> -->
|
||||
</view>
|
||||
<view class="content">
|
||||
<view class="title more-t">{{item.productName}}</view>
|
||||
<view class="price flex ai-center">
|
||||
<!-- <image class="label-vip" :src="webUrl+'/20221118104357701129.png'" mode="scaleToFill"></image> -->
|
||||
<text>¥{{item.price}}</text>
|
||||
</view>
|
||||
<view class="cart-box flex ai-center jc-between">
|
||||
<view class="flex ai-center">
|
||||
<image class="icon-fire" :src="webUrl+'/20220214125642215597.png'" mode="scaleToFill"></image>
|
||||
<text>{{item.sales}}人已购买</text>
|
||||
</view>
|
||||
<image class="icon-cart" :src="webUrl+'/20220214125543267695.png'" mode="scaleToFill"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
getYxStoreSeckillIndex,
|
||||
getYxStoreSeckillPageList
|
||||
} from "@/api/goods";
|
||||
import CountDown from "@/components/CountDown.vue";
|
||||
export default {
|
||||
components: {
|
||||
CountDown
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
webUrl: this.$VUE_APP_RESOURCES_URL,
|
||||
seckillTime: [],
|
||||
seckillTimeIndex: 0,
|
||||
page: 1,
|
||||
list: [],
|
||||
endReach: false,
|
||||
timeId: null,
|
||||
nextList: []
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.fetchSession();
|
||||
},
|
||||
onReachBottom() {
|
||||
if (this.endReach) return;
|
||||
this.page++;
|
||||
this.fetchList(this.page);
|
||||
},
|
||||
methods: {
|
||||
fetchSession() {
|
||||
getYxStoreSeckillIndex().then(({
|
||||
data
|
||||
}) => {
|
||||
this.seckillTime = data.seckillTime;
|
||||
this.seckillTimeIndex = data.seckillTimeIndex;
|
||||
|
||||
this.timeId = this.seckillTime[this.seckillTimeIndex].id
|
||||
this.fetchList(this.page);
|
||||
|
||||
if (this.seckillTime.length > this.seckillTimeIndex) {
|
||||
console.log("test",this.seckillTime[this.seckillTimeIndex + 1].id)
|
||||
getYxStoreSeckillPageList(1, 10, this.seckillTime[this.seckillTimeIndex + 1].id).then(({
|
||||
data
|
||||
}) => {
|
||||
this.nextList = data
|
||||
})
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
fetchList(page) {
|
||||
getYxStoreSeckillPageList(page, 10, this.timeId).then(({
|
||||
data
|
||||
}) => {
|
||||
if (data.length > 0) {
|
||||
data.map(item => this.list.push(item));
|
||||
} else {
|
||||
this.endReach = true;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
goGoodsConByProductID(item) {
|
||||
this.$yrouter.push({
|
||||
path: '/pages/shop/GoodsCon/index',
|
||||
query: {
|
||||
id: item.productId,
|
||||
activityId:item.id,
|
||||
from:"kill"
|
||||
}
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
.page-seckill {
|
||||
min-height: 100vh;
|
||||
padding-top: 24rpx;
|
||||
background: #FFEDE0;
|
||||
}
|
||||
|
||||
.next-box {
|
||||
height: 200rpx;
|
||||
box-sizing: border-box;
|
||||
margin: 0 32rpx;
|
||||
padding: 10rpx 0 18rpx;
|
||||
background: #fff;
|
||||
opacity: 1;
|
||||
border-radius: 12rpx;
|
||||
|
||||
.info {
|
||||
padding: 0 18rpx;
|
||||
|
||||
text {
|
||||
font-size: 24rpx;
|
||||
font-weight: bold;
|
||||
line-height: 34rpx;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.red {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
line-height: 48rpx;
|
||||
color: #FD685D;
|
||||
}
|
||||
}
|
||||
|
||||
.img-box {
|
||||
width: 100%;
|
||||
margin-top: 24rpx;
|
||||
overflow-x: auto;
|
||||
|
||||
image {
|
||||
flex-shrink: 0;
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
margin-left: 24rpx;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
image:first-child {
|
||||
margin-left: 18rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.img-box::-webkit-scrollbar {
|
||||
width: 0 !important
|
||||
}
|
||||
}
|
||||
|
||||
.header {
|
||||
margin: 40rpx 32rpx 20rpx;
|
||||
|
||||
.title {
|
||||
margin-right: 28rpx;
|
||||
color: #333;
|
||||
line-height: 48rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.sub-title {
|
||||
line-height: 32rpx;
|
||||
font-size: 22rpx;
|
||||
color: #A1A1A1;
|
||||
}
|
||||
|
||||
.count-box {
|
||||
margin-top: 6rpx;
|
||||
font-size: 24rpx;
|
||||
|
||||
/deep/ .time {
|
||||
.styleAll {
|
||||
display: inline-block;
|
||||
height: 40rpx;
|
||||
line-height: 40rpx;
|
||||
padding: 0 4rpx;
|
||||
background: #ED0F0F;
|
||||
color: #fff;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.timeTxt {
|
||||
margin: 0 4rpx;
|
||||
color: #8D8D8D;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.more {
|
||||
margin-top: 8rpx;
|
||||
color: #7C7C7C;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.list {
|
||||
margin: 0 32rpx;
|
||||
|
||||
.item:nth-child(2n) {
|
||||
margin-left: 22rpx;
|
||||
}
|
||||
|
||||
.item {
|
||||
width: 332rpx;
|
||||
margin-bottom: 24rpx;
|
||||
border-radius: 8rpx;
|
||||
background: #fff;
|
||||
|
||||
.img-box {
|
||||
position: relative;
|
||||
|
||||
.main {
|
||||
width: 332rpx;
|
||||
height: 332rpx;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.label {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 94rpx;
|
||||
height: 42rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
.label-vip {
|
||||
width: 40rpx;
|
||||
height: 24rpx;
|
||||
margin-right: 6rpx;
|
||||
}
|
||||
|
||||
.icon-fire {
|
||||
width: 24rpx;
|
||||
height: 24rpx;
|
||||
}
|
||||
|
||||
.icon-cart {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
}
|
||||
|
||||
.title {
|
||||
margin: 8rpx 4rpx 0 10rpx;
|
||||
font-size: 26rpx;
|
||||
font-weight: bold;
|
||||
line-height: 36rpx;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.price {
|
||||
padding: 4rpx 10rpx 10rpx;
|
||||
font-size: 26rpx;
|
||||
font-weight: bold;
|
||||
line-height: 38rpx;
|
||||
color: #ED0F0F;
|
||||
|
||||
.del {
|
||||
margin-left: 16rpx;
|
||||
text-decoration: line-through;
|
||||
font-size: 20rpx;
|
||||
line-height: 30rpx;
|
||||
font-weight: normal;
|
||||
color: #A5A5A5;
|
||||
}
|
||||
}
|
||||
|
||||
.cart-box {
|
||||
padding: 10rpx 12rpx 12rpx;
|
||||
border-top: 1rpx solid #EFEFEF;
|
||||
|
||||
text {
|
||||
font-size: 22rpx;
|
||||
line-height: 32rpx;
|
||||
color: #333333;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,241 @@
|
||||
<template>
|
||||
<view class="page-v4">
|
||||
<view class="top-box flex ai-center">
|
||||
<image class="logo" :src="logo" mode="scaleToFill"></image>
|
||||
<view>
|
||||
<view class="main">{{ merchantName }}</view>
|
||||
<view class="sub">共{{ list.length }}件商品</view>
|
||||
</view>
|
||||
|
||||
<image class="btn-service" :src="webUrl+'/20221008161418239500.png'" @click="goRoom"/>
|
||||
</view>
|
||||
|
||||
<view class="nav-box flex jc-between ai-center">
|
||||
<text :class="{active:navIndex===index}" v-for="(item,index) in navList" :key="index"
|
||||
@click="changeNav(index)">{{ item.name }}
|
||||
</text>
|
||||
</view>
|
||||
|
||||
<view class="list flex flex-wrap">
|
||||
<view class="item" v-for="item in list" :key="item">
|
||||
<view class="img-box" @click="goGoods(item.id)">
|
||||
<image class="main" :src="item.image" mode="scaleToFill"></image>
|
||||
</view>
|
||||
<view class="content" @click="goGoods(item.id)">
|
||||
<view class="base-box">
|
||||
<view class="title more-t">{{ item.storeName }}</view>
|
||||
<view class="price flex ai-center">
|
||||
<!-- <image class="label-vip" :src="webUrl+'/20221118104357701129.png'" mode="scaleToFill"></image> -->
|
||||
<text>¥{{ item.price }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="cart-box flex ai-center jc-between">
|
||||
<view class="flex ai-center">
|
||||
<image class="icon-fire" :src="webUrl+'/20221118092713277343.png'" mode="scaleToFill"></image>
|
||||
<text>{{ item.sales }}人已购买</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
fetchGoods
|
||||
} from "@/api/shop";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
webUrl: this.$VUE_APP_RESOURCES_URL,
|
||||
merId: null,
|
||||
merchantName: "",
|
||||
list: [],
|
||||
orderBy: "sortBySort",
|
||||
logo: "",
|
||||
navIndex: 0,
|
||||
navList: [{
|
||||
key: "sortBySort",
|
||||
name: "综合排序"
|
||||
},
|
||||
{
|
||||
key: "sortBySales",
|
||||
name: "销量最高"
|
||||
},
|
||||
{
|
||||
key: "sortByNew",
|
||||
name: "新品上新"
|
||||
}, {
|
||||
key: "sortByPrice",
|
||||
name: "价格最高"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
onLoad: function (option) {
|
||||
this.merId = option.id
|
||||
this.merchantName = option.name
|
||||
uni.setNavigationBarTitle({
|
||||
title: this.merchantName
|
||||
})
|
||||
this.getInfo()
|
||||
},
|
||||
methods: {
|
||||
changeNav(index) {
|
||||
if (this.navIndex === index) return;
|
||||
this.navIndex = index;
|
||||
this.orderBy = this.navList[index].key
|
||||
this.getInfo()
|
||||
},
|
||||
getInfo() {
|
||||
fetchGoods(this.merId, this.orderBy).then(({
|
||||
data
|
||||
}) => {
|
||||
this.list = data;
|
||||
if (this.list.length > 0) this.logo = this.list[0].merLogo;
|
||||
})
|
||||
},
|
||||
goGoods(id) {
|
||||
this.$yrouter.push("/pages/shop/GoodsCon/index?id=" + id)
|
||||
},
|
||||
goRoom(){
|
||||
uni.navigateTo({
|
||||
url: `/pkg_common/views/room?id=${this.merId}`
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.top-box {
|
||||
position: relative;
|
||||
margin: 30rpx 32rpx 24rpx;
|
||||
|
||||
.btn-service {
|
||||
position: absolute;
|
||||
top: 30rpx;
|
||||
right: 0;
|
||||
width: 144rpx;
|
||||
height: 44rpx;
|
||||
}
|
||||
|
||||
.logo {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
margin-right: 16rpx;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.main {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
line-height: 48rpx;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.sub {
|
||||
margin-top: 6rpx;
|
||||
font-size: 24rpx;
|
||||
line-height: 34rpx;
|
||||
color: #9E9E9E;
|
||||
}
|
||||
}
|
||||
|
||||
.nav-box {
|
||||
height: 60rpx;
|
||||
margin: 0 32rpx 12rpx;
|
||||
padding: 0 32rpx 0 36rpx;
|
||||
background: #fff;
|
||||
|
||||
text {
|
||||
font-size: 24rpx;
|
||||
line-height: 34rpx;
|
||||
color: #9E9E9E;
|
||||
}
|
||||
|
||||
.active {
|
||||
color: #FD685D;
|
||||
}
|
||||
}
|
||||
|
||||
.list {
|
||||
margin: 0 32rpx;
|
||||
|
||||
.item:nth-child(2n) {
|
||||
margin-left: 22rpx;
|
||||
}
|
||||
|
||||
.item {
|
||||
width: 332rpx;
|
||||
margin-bottom: 24rpx;
|
||||
border-radius: 8rpx;
|
||||
background: #fff;
|
||||
|
||||
.img-box {
|
||||
position: relative;
|
||||
|
||||
.main {
|
||||
width: 332rpx;
|
||||
height: 332rpx;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
.base-box {
|
||||
height: 140rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.label-vip {
|
||||
width: 40rpx;
|
||||
height: 24rpx;
|
||||
margin-right: 6rpx;
|
||||
}
|
||||
|
||||
.icon-fire {
|
||||
width: 24rpx;
|
||||
height: 24rpx;
|
||||
}
|
||||
|
||||
.icon-cart {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
}
|
||||
|
||||
.title {
|
||||
margin: 8rpx 4rpx 0 10rpx;
|
||||
font-size: 26rpx;
|
||||
font-weight: bold;
|
||||
line-height: 36rpx;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.price {
|
||||
padding: 4rpx 10rpx 10rpx;
|
||||
font-size: 26rpx;
|
||||
font-weight: bold;
|
||||
line-height: 38rpx;
|
||||
color: #ED0F0F;
|
||||
}
|
||||
|
||||
.cart-box {
|
||||
padding: 8rpx 16rpx 14rpx 18rpx;
|
||||
border-top: 1rpx solid #EFEFEF;
|
||||
|
||||
text {
|
||||
margin-left: 6rpx;
|
||||
font-size: 24rpx;
|
||||
font-weight: bold;
|
||||
line-height: 34rpx;
|
||||
color: #8D8D8D;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,129 @@
|
||||
<template>
|
||||
<view class="page-v4">
|
||||
<uni-search-bar placeholder="搜索店铺" @confirm="fetchList" @input="input"></uni-search-bar>
|
||||
|
||||
<view class="item" v-for="item in list" :key="item">
|
||||
<view class="top-box">
|
||||
<view class="flex ai-center">
|
||||
<image class="logo" :src="item.merchant.avatar" mode="scaleToFill"></image><text>{{item.merchant.name}}</text>
|
||||
</view>
|
||||
<view class="right flex ai-center" v-if="item.hasNew==1">
|
||||
<image class="icon" :src="webUrl+'/20220218213627732423.png'" mode="scaleToFill"></image><text>有上新</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="img-box flex">
|
||||
<image class="img-item" :src="img.image" mode="scaleToFill" v-for="img in item.productList" :key="img"
|
||||
@click="goGoods(img.id)"></image>
|
||||
<view class="last-img" @click="goDetail(item.merchant.id,item.merchant.name)" v-if="item.productList.length>0">
|
||||
<image class="img-item" :src="item.productList[0].image" mode="scaleToFill"></image>
|
||||
<image class="img-item img-mask" :src="webUrl+'/20220218220333915755.png'" mode="scaleToFill"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
fetchShop
|
||||
} from "@/api/shop";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
webUrl: this.$VUE_APP_RESOURCES_URL,
|
||||
keyword: "",
|
||||
list: []
|
||||
}
|
||||
},
|
||||
onLoad: function() {
|
||||
this.fetchList()
|
||||
},
|
||||
methods: {
|
||||
fetchList() {
|
||||
fetchShop(this.keyword).then(({
|
||||
data
|
||||
}) => this.list = data)
|
||||
},
|
||||
input(value) {
|
||||
this.keyword = value
|
||||
},
|
||||
goDetail(id,name) {
|
||||
this.$yrouter.push(`/v4/views/shop/detail?id=${id}&name=${name}`)
|
||||
},
|
||||
goGoods(id) {
|
||||
this.$yrouter.push("/pages/shop/GoodsCon/index?id=" + id)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.uni-searchbar__box {
|
||||
margin-bottom: 32rpx;
|
||||
border-radius: 44px !important;
|
||||
background: rgba(255, 255, 255, 1) !important;
|
||||
}
|
||||
|
||||
.logo {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
border-radius: 50%;
|
||||
margin-right: 12rpx;
|
||||
}
|
||||
|
||||
.icon {
|
||||
width: 20rpx;
|
||||
height: 20rpx;
|
||||
margin-right: 4rpx;
|
||||
}
|
||||
|
||||
.img-item {
|
||||
width: 140rpx;
|
||||
height: 140rpx;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.item {
|
||||
margin: 0 32rpx 24rpx;
|
||||
background: #fff;
|
||||
border-radius: 4px;
|
||||
|
||||
.top-box {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 12rpx 16rpx;
|
||||
border-bottom: 1rpx solid #EFEFEF;
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.right {
|
||||
font-size: 20rpx;
|
||||
color: #FD685D;
|
||||
}
|
||||
|
||||
.img-box {
|
||||
padding: 12rpx 18rpx 16rpx;
|
||||
|
||||
.img-item {
|
||||
vertical-align: middle;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.last-img {
|
||||
position: relative;
|
||||
|
||||
.img-mask {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,265 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="fixed-top">
|
||||
<view class="city-box" @click="goCity">
|
||||
<image :src="webUrl+'/20220903142929759087.png'" mode="scaleToFill"></image>
|
||||
<text>{{ cityName }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="list flex flex-wrap" v-if="list.length">
|
||||
<view class="item" v-for="item in list" :key="item" @click="goDetils(item.id)">
|
||||
<view class="img-box">
|
||||
<image class="main" :src="item.image" mode="scaleToFill"></image>
|
||||
<image class="label" :src="webUrl+'/20220525103739004011.png'" mode="scaleToFill"></image>
|
||||
</view>
|
||||
<view class="content">
|
||||
<view class="title more-t">{{ item.storeName }}</view>
|
||||
<view class="price flex ai-center">
|
||||
<!-- <image class="label-vip" :src="webUrl+'/20221118104357701129.png'" mode="scaleToFill"></image> -->
|
||||
<text>¥{{ item.price }}</text>
|
||||
</view>
|
||||
<view class="cart-box flex ai-center jc-between">
|
||||
<view class="flex ai-center">
|
||||
<image class="icon-fire" :src="webUrl+'/20220214125642215597.png'" mode="scaleToFill"></image>
|
||||
<text>{{ item.sales }}人已购买</text>
|
||||
</view>
|
||||
<image class="icon-cart" :src="webUrl+'/20220214125543267695.png'" mode="scaleToFill"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="v4-nodata" style="margin-top: 120rpx;" v-else>
|
||||
<image src="@/static/images/img_nodata.png" mode="scaleToFill"/>
|
||||
<view class="text">暂无数据</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
fetchSpecialty
|
||||
} from "@/api/shop";
|
||||
import config from '@/utils/mapConfig';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
webUrl: this.$VUE_APP_RESOURCES_URL,
|
||||
page: 1,
|
||||
cityName: "丽江市",
|
||||
list: []
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
let memCityName = uni.getStorageSync("cityName")
|
||||
if (memCityName.length) {
|
||||
this.cityName = memCityName;
|
||||
this.page = 1;
|
||||
this.list = [];
|
||||
this.fetchList(this.cityName);
|
||||
uni.removeStorageSync("cityName")
|
||||
}
|
||||
},
|
||||
onReachBottom: function () {
|
||||
this.page++;
|
||||
this.fetchList(this.cityName);
|
||||
},
|
||||
methods: {
|
||||
goCity() {
|
||||
uni.redirectTo({
|
||||
url: `/components/chose-city/chose-city?type=0&city=${this.cityName}`
|
||||
})
|
||||
},
|
||||
goDetils(id) {
|
||||
this.$yrouter.push({
|
||||
path: "/pages/shop/GoodsCon/index",
|
||||
query: {
|
||||
id,
|
||||
from: "spe"
|
||||
}
|
||||
})
|
||||
},
|
||||
fetchList(cityName) {
|
||||
fetchSpecialty(this.page, cityName).then(res => {
|
||||
if (res.data.length > 0) {
|
||||
res.data.forEach(item => {
|
||||
this.list.push(item);
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
//获取当前定位地址
|
||||
getCurAddress() {
|
||||
var that = this;
|
||||
//定位
|
||||
uni.showLoading({
|
||||
title: '定位中...'
|
||||
});
|
||||
|
||||
uni.getLocation({
|
||||
type: 'wgs84',
|
||||
success: function (res) {
|
||||
let latitude = res.latitude;
|
||||
let longitude = res.longitude;
|
||||
|
||||
console.log('latitude:' + latitude + 'longitude:' + longitude)
|
||||
|
||||
// #ifdef H5
|
||||
Vue.jsonp(
|
||||
'https://apis.map.qq.com/ws/geocoder/v1/?location=' + latitude + ',' + longitude + '&key=' +
|
||||
config.key, {
|
||||
output: 'jsonp',
|
||||
}).then(json => {
|
||||
// Success.
|
||||
uni.hideLoading();
|
||||
that.cityName = json.result.ad_info.city;
|
||||
//定位成功刷新数据
|
||||
that.fetchList()
|
||||
}).catch(err => {
|
||||
// Failed.
|
||||
console.log('地址解析失败:' + JSON.stringify(err));
|
||||
uni.hideLoading();
|
||||
})
|
||||
// #endif
|
||||
|
||||
// #ifndef H5
|
||||
uni.request({
|
||||
url: 'https://apis.map.qq.com/ws/geocoder/v1/?location=' + latitude + ',' + longitude +
|
||||
'&key=' + config.key,
|
||||
success: function (res) {
|
||||
uni.hideLoading();
|
||||
|
||||
that.cityName = res.data.result.ad_info.city;
|
||||
|
||||
//定位成功刷新数据
|
||||
that.fetchList()
|
||||
},
|
||||
fail: function (res) {
|
||||
console.log('地址解析失败');
|
||||
uni.hideLoading();
|
||||
},
|
||||
complete: function () {
|
||||
}
|
||||
});
|
||||
// #endif
|
||||
},
|
||||
fail: function (res) {
|
||||
uni.hideLoading();
|
||||
}
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.fixed-top {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
padding: 22rpx 0 20rpx;
|
||||
background: #F5F5FA;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.city-box {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
margin-left: 32rpx;
|
||||
padding: 8rpx 18rpx 8rpx 16rpx;
|
||||
border-radius: 30px;
|
||||
background: #fff;
|
||||
|
||||
image {
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
margin-right: 4rpx;
|
||||
}
|
||||
|
||||
text {
|
||||
color: #333;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.list {
|
||||
margin: 96rpx 32rpx 0;
|
||||
|
||||
.item:nth-child(2n) {
|
||||
margin-left: 22rpx;
|
||||
}
|
||||
|
||||
.item {
|
||||
width: 332rpx;
|
||||
margin-bottom: 24rpx;
|
||||
border-radius: 8rpx;
|
||||
background: #fff;
|
||||
|
||||
.img-box {
|
||||
position: relative;
|
||||
|
||||
.main {
|
||||
width: 332rpx;
|
||||
height: 332rpx;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.label {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 94rpx;
|
||||
height: 42rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
.label-vip {
|
||||
width: 40rpx;
|
||||
height: 24rpx;
|
||||
margin-right: 6rpx;
|
||||
}
|
||||
|
||||
.icon-fire {
|
||||
width: 24rpx;
|
||||
height: 24rpx;
|
||||
}
|
||||
|
||||
.icon-cart {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
}
|
||||
|
||||
.title {
|
||||
margin: 8rpx 4rpx 0 10rpx;
|
||||
font-size: 26rpx;
|
||||
font-weight: bold;
|
||||
line-height: 36rpx;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.price {
|
||||
padding: 4rpx 10rpx 10rpx;
|
||||
font-size: 26rpx;
|
||||
font-weight: bold;
|
||||
line-height: 38rpx;
|
||||
color: #ED0F0F;
|
||||
}
|
||||
|
||||
.cart-box {
|
||||
padding: 10rpx 12rpx 12rpx;
|
||||
border-top: 1rpx solid #EFEFEF;
|
||||
|
||||
text {
|
||||
font-size: 22rpx;
|
||||
line-height: 32rpx;
|
||||
color: #333333;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,146 @@
|
||||
<template>
|
||||
<view class="page-v4">
|
||||
<uni-search-bar class="search" placeholder="搜索店铺" bgColor="#fff" @confirm="search" @input="input"></uni-search-bar>
|
||||
<view class="city-box">
|
||||
<image :src="webUrl+'/20220903142929759087.png'" mode="scaleToFill"></image>
|
||||
<text>丽江市</text>
|
||||
</view>
|
||||
|
||||
<view class="main-wrap">
|
||||
<view class="list-box">
|
||||
<view class="img-pic">
|
||||
<image src="https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=2293895315,941305116&fm=15&gp=0.jpg"
|
||||
mode="scaleToFill"></image>
|
||||
</view>
|
||||
<view class="list-title">
|
||||
草莓
|
||||
</view>
|
||||
</view>
|
||||
<view class="list-box">
|
||||
<view class="img-pic">
|
||||
<image src="https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2534506313,1688529724&fm=26&gp=0.jpg"
|
||||
mode="scaleToFill"></image>
|
||||
</view>
|
||||
<view class="list-title">
|
||||
香蕉
|
||||
<view>subtitle</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="list-box">
|
||||
<view class="img-pic">
|
||||
<image src="https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3571319963,2190929172&fm=26&gp=0.jpg"
|
||||
mode="scaleToFill"></image>
|
||||
</view>
|
||||
<view class="list-title">
|
||||
杨桃
|
||||
</view>
|
||||
</view>
|
||||
<view class="list-box">
|
||||
<view class="img-pic">
|
||||
<image src="https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=2356795443,149489428&fm=26&gp=0.jpg"
|
||||
mode="scaleToFill"></image>
|
||||
</view>
|
||||
<view class="list-title">
|
||||
车厘子
|
||||
</view>
|
||||
</view>
|
||||
<view class="list-box">
|
||||
<view class="img-pic">
|
||||
<image src="https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=201658450,2328203442&fm=26&gp=0.jpg"
|
||||
mode="scaleToFill"></image>
|
||||
</view>
|
||||
<view class="list-title">
|
||||
苹果
|
||||
</view>
|
||||
</view>
|
||||
<view class="list-box">
|
||||
<view class="img-pic">
|
||||
<image src="https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1572231494,1459024433&fm=26&gp=0.jpg"
|
||||
mode="scaleToFill"></image>
|
||||
</view>
|
||||
<view class="list-title">
|
||||
橙子
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
webUrl: this.$VUE_APP_RESOURCES_URL
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.search {
|
||||
.uni-searchbar {
|
||||
padding: 20rpx 32rpx 12rpx !important;
|
||||
|
||||
.uni-searchbar__box {
|
||||
border-radius: 44px !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.city-box {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
margin-left: 32rpx;
|
||||
padding: 8rpx 18rpx 8rpx 16rpx;
|
||||
border-radius: 30px;
|
||||
background: #fff;
|
||||
|
||||
image {
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
margin-right: 4rpx;
|
||||
}
|
||||
|
||||
text {
|
||||
color: #333;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.main-wrap {
|
||||
column-count: 2;
|
||||
// column-gap: 10rpx;
|
||||
margin: 24rpx 32rpx;
|
||||
}
|
||||
|
||||
.list-box {
|
||||
// margin: 10rpx;
|
||||
// width: 50%;
|
||||
// width: calc(100% / 2 - 20rpx);
|
||||
width: 332rpx;
|
||||
margin-bottom: 24rpx;
|
||||
background-color: #fff;
|
||||
border-radius: 8rpx;
|
||||
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
// .img-pic {
|
||||
// width: 100%;
|
||||
// }
|
||||
|
||||
.img-pic>image {
|
||||
width: 100%;
|
||||
height: 332rpx;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.list-title {
|
||||
margin: 20rpx;
|
||||
font-size: 30rpx;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user