index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. <template>
  2. <view>
  3. <u-navbar leftIconSize="0" title="详情" :border="true" :placeholder="true" :autoBack="true" bgColor="#fff" />
  4. <view class="lucky">
  5. <!-- <view class="lucky-number">
  6. <view class="flex lucky-number-circle">
  7. <view class="title">幸运数字</view>
  8. <view class="num" v-if="info.status == 1">?</view>
  9. <view class="luckyNum" v-else>{{ info.plainLuckyNum }}</view>
  10. </view>
  11. </view>
  12. <view class="lucky-title">
  13. <view class="txt">{{ info.title }}</view>
  14. <view class="id">盲票序列号:{{ info.serialNo }}</view>
  15. </view>
  16. <view class="flex lucky-btn">
  17. <view class="pay" @click="pay" v-if="info.status == 1">支付{{ info.salePrice / 100 }}元 立即查看</view>
  18. <view class="pay" @click="saveImg" v-else>保存至手机相册</view>
  19. </view> -->
  20. </view>
  21. <u-overlay :show="luckyShow" zIndex="100">
  22. <view class="flex luck-warp">
  23. <view class="luck-info">
  24. <view class="flex luck-info-image">
  25. <image class="image1" src="../../static/icon/lucky_bg.png" mode="" v-if="info.status == 1"></image>
  26. <image class="image2" src="../../static/icon/lucky_bg2.png" mode="" v-else></image>
  27. </view>
  28. <view :class="{ 'flex luck-info-content mat': info.status == 1, 'flex luck-info-content mat2': info.status != 1 }">
  29. <view class="title">幸运数字</view>
  30. <view class="name">测试盲票</view>
  31. <view class="num">盲票序列号:{{ info.serialNo }}</view>
  32. </view>
  33. <view class="flex luck-info-tip" v-if="info.status == 2">
  34. <view class="tip">请刮开纸质票面的数字,与此幸运数字相同的就是所中奖项</view>
  35. </view>
  36. <view class="flex luck-info-btn">
  37. <view class="btn" v-if="info.status == 1">支付{{ info.salePrice / 100 }}元 立即查看</view>
  38. <view class="btn" v-else>保存至手机相册</view>
  39. </view>
  40. <view class="flex luck-info-num" v-if="info.status == 2">23</view>
  41. <view class="flex luck-info-close">
  42. <u-icon name="close" color="#333" size="20"></u-icon>
  43. </view>
  44. </view>
  45. </view>
  46. </u-overlay>
  47. <pay-popup :pay-show="payShow" :pay-info="payInfo" @close="close" @success="getDetailInfo" />
  48. <u-popup :show="showNull" :round="10" mode="center" :safeAreaInsetBottom="false">
  49. <view class="null-prize">
  50. <view class="title">该盲票已兑奖</view>
  51. <view class="btn" @click="toIndex">确认</view>
  52. </view>
  53. </u-popup>
  54. <hch-poster ref="hchPoster" @cancel="handleCancel" :posterData.sync="posterData" @previewImage='previewImage'
  55. @canvasConfirm="toIndex" />
  56. </view>
  57. </template>
  58. <script>
  59. import env from '../../config/env.js'
  60. import $http from '@/utils/request.js'
  61. import PayPopup from '../../components/pay-popup/pay-popup.vue'
  62. import HchPoster from "../../components/hch-poster/hch-poster.vue"
  63. export default {
  64. components: {
  65. PayPopup,
  66. HchPoster
  67. },
  68. data() {
  69. return {
  70. serialNo: '',
  71. info: '',
  72. payInfo: {},
  73. payShow: false,
  74. payLookFlag: true,
  75. showNull: false,
  76. posterData: {},
  77. luckyShow: true,
  78. status: 2
  79. };
  80. },
  81. onLoad(options) {
  82. if (options.id) {
  83. console.log(options);
  84. this.serialNo = options.id
  85. }
  86. if (options.q) {
  87. let url = JSON.stringify(options.q)
  88. this.serialNo = url.substring(url.length - 22, url.length - 1)
  89. }
  90. },
  91. onShow() {
  92. if (this.serialNo && this.payLookFlag) {
  93. this.getDetail()
  94. }
  95. },
  96. methods: {
  97. getDetail() {
  98. uni.showLoading({
  99. title: '加载中'
  100. });
  101. $http.post('/api/v1/mp/user/ticket/queryLuckyNum', {
  102. serialNo: this.serialNo,
  103. noToken: true
  104. }).then(res => {
  105. uni.hideLoading();
  106. if (res.code == 0) {
  107. if (res.data.status == 1) {
  108. this.info = res.data
  109. } else if (res.data.status == 2) {
  110. if (uni.getStorageSync('token')) {
  111. uni.redirectTo({
  112. url: `/pages/choice/index?id=${ res.data.ticketId }`
  113. })
  114. } else {
  115. uni.showModal({
  116. title: '提示',
  117. content: '您未登录或登录失效!',
  118. confirmText: '去登录',
  119. showCancel: false,
  120. success(res) {
  121. if (res.confirm) {
  122. uni.navigateTo({
  123. url: "/pages/login/index"
  124. })
  125. }
  126. }
  127. })
  128. }
  129. } else {
  130. this.showNull = true
  131. }
  132. } else {
  133. uni.$u.toast('该盲票不存在!');
  134. setTimeout(() => {
  135. uni.switchTab({
  136. url: '/pages/index/index'
  137. })
  138. }, 1000)
  139. }
  140. }).catch(() => {
  141. uni.hideLoading();
  142. })
  143. },
  144. getDetailInfo() {
  145. this.payShow = false
  146. uni.showLoading({
  147. title: '加载中'
  148. });
  149. $http.post('/api/v1/mp/user/ticket/queryLuckyNum', {
  150. serialNo: this.serialNo,
  151. noToken: true
  152. }).then(res => {
  153. uni.hideLoading();
  154. if (res.code == 0) {
  155. this.info = res.data
  156. let num = res.data.plainLuckyNum
  157. this.posterData.num.text =
  158. this.posterData = {
  159. poster: {
  160. //根据屏幕大小自动生成图片背景大小
  161. url: env.filePublic + this.info.picUrl, //图片地址
  162. r: 10, //圆角半径
  163. w: 300, //图片宽度
  164. h: 480, //图片高度
  165. p: 20 //图片内边距padding
  166. },
  167. square3: {
  168. x: 100,
  169. y: 100,
  170. r: 0, //圆角半径
  171. w: 240, //宽度
  172. h: 180, //高度
  173. mt: 65
  174. },
  175. title: {
  176. text: "幸运数字", //文本
  177. fontSize: 20, //字体大小
  178. color: "#000", //颜色
  179. lineHeight: 25, //行高
  180. mt: 20, //margin-top
  181. align: 'center'
  182. },
  183. num: {
  184. text: num + '', //文本
  185. fontSize: 40, //字体大小
  186. color: "#fff", //颜色
  187. lineHeight: 25, //行高
  188. mt: 20, //margin-top
  189. align: 'center'
  190. },
  191. txt: {
  192. text: res.data.title, //文本
  193. fontSize: 16, //字体大小
  194. color: "#000", //颜色
  195. lineHeight: 25, //行高
  196. mt: 20, //margin-top
  197. align: 'center'
  198. },
  199. }
  200. }
  201. }).catch(() => {
  202. uni.hideLoading();
  203. })
  204. },
  205. close() {
  206. this.payShow = false
  207. },
  208. pay() {
  209. let data = {
  210. ticketId: this.info.ticketId,
  211. autoCoupon: 1
  212. }
  213. this.payLookFlag = false
  214. uni.showLoading({
  215. title: '加载中'
  216. });
  217. $http.post('/api/v1/mp/user/ticket/order/settle', data).then(res => {
  218. uni.hideLoading();
  219. if (res.code == 0) {
  220. let info = {
  221. ...res.data,
  222. ...this.info,
  223. picUrl: env.filePublic + res.data.picUrl,
  224. }
  225. this.payInfo = info
  226. this.payShow = true
  227. }
  228. }).catch(() => {
  229. uni.hideLoading();
  230. })
  231. },
  232. screen() {
  233. },
  234. toIndex() {
  235. uni.switchTab({
  236. url: '/pages/index/index'
  237. })
  238. },
  239. previewImage() {
  240. },
  241. saveImg() {
  242. this.$refs.hchPoster.posterShow()
  243. },
  244. handleCancel() {
  245. },
  246. toIndex() {
  247. uni.switchTab({
  248. url: '/pages/index/index'
  249. })
  250. },
  251. }
  252. }
  253. </script>
  254. <style lang="scss" scoped>
  255. .luck-warp {
  256. height: 100%;
  257. .luck-info {
  258. position: relative;
  259. width: 85%;
  260. border-radius: 40rpx;
  261. background-color: #fff;
  262. .luck-info-image{
  263. margin-bottom: 30rpx;
  264. .image1{
  265. width: 400rpx;
  266. height: 400rpx;
  267. margin-top: -200rpx;
  268. }
  269. .image2{
  270. width: 450rpx;
  271. height: 450rpx;
  272. margin-top: -280rpx;
  273. // padding-bottom: 50rpx;
  274. }
  275. }
  276. .luck-info-tip{
  277. .tip{
  278. width: 460rpx;
  279. height: 100rpx;
  280. line-height: 50rpx;
  281. font-size: 24rpx;
  282. padding: 0 26rpx;
  283. color: #666666;
  284. text-align: center;
  285. background: rgba(255, 109, 28, 0.2);
  286. }
  287. }
  288. .luck-info-content{
  289. flex-direction: column;
  290. .title{
  291. line-height: 68rpx;
  292. font-size: 48rpx;
  293. margin-bottom: 36rpx;
  294. }
  295. .name{
  296. font-size: 40rpx;
  297. line-height: 56rpx;
  298. margin-bottom: 20rpx;
  299. }
  300. .num{
  301. font-size: 32rpx;
  302. color: #666666;
  303. line-height: 44rpx;
  304. }
  305. }
  306. .mat{
  307. margin-bottom: 140rpx;
  308. }
  309. .mat2{
  310. margin-bottom: 20rpx;
  311. }
  312. .luck-info-btn{
  313. margin-top: 20rpx;
  314. .btn{
  315. width: 530rpx;
  316. height: 100rpx;
  317. line-height: 100rpx;
  318. color: #FFFFFF;
  319. font-size: 48rpx;
  320. text-align: center;
  321. border-radius: 200rpx;
  322. background: linear-gradient(180deg, #FFB266 0%, #FFB266 0%, #FF843A 100%, #FF843A 100%);
  323. box-shadow: 0px 4px 10px 0px rgba(182, 85, 24, 0.6);
  324. margin-bottom: 80rpx;
  325. }
  326. }
  327. .luck-info-num{
  328. position: absolute;
  329. top: -60rpx;
  330. width: 100%;
  331. font-size: 80rpx;
  332. color: #FFFFFF;
  333. }
  334. .luck-info-close{
  335. position: absolute;
  336. width: 70rpx;
  337. height: 70rpx;
  338. background-color: #F8F8F8;
  339. border-radius: 50%;
  340. right: 10rpx;
  341. top: -80rpx;
  342. }
  343. }
  344. }
  345. .lucky {
  346. // width: 100%;
  347. // min-height: calc(100vh - 44px - var(--status-bar-height));
  348. // background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/background.png) center center;
  349. // &-number {
  350. // padding-top: 300rpx;
  351. // &-circle {
  352. // box-sizing: border-box;
  353. // flex-direction: column;
  354. // width: 336rpx;
  355. // height: 336rpx;
  356. // background-color: #FFFFFF;
  357. // border-radius: 50%;
  358. // margin: auto;
  359. // .title {
  360. // margin-bottom: 20rpx;
  361. // }
  362. // .num {
  363. // font-size: 120rpx;
  364. // color: #E86737;
  365. // }
  366. // .luckyNum {
  367. // font-size: 120rpx;
  368. // color: #E86737;
  369. // }
  370. // }
  371. // }
  372. // &-title {
  373. // margin-top: 40rpx;
  374. // margin-bottom: 200rpx;
  375. // .txt {
  376. // text-align: center;
  377. // font-size: 36rpx;
  378. // font-weight: bold;
  379. // line-height: 50rpx;
  380. // margin-bottom: 8rpx;
  381. // }
  382. // .id {
  383. // line-height: 40rpx;
  384. // text-align: center;
  385. // color: #888787;
  386. // }
  387. // }
  388. // &-tip {
  389. // padding: 0 40rpx;
  390. // color: #333;
  391. // width: 80vw;
  392. // height: 200rpx;
  393. // ;
  394. // border-radius: 10rpx;
  395. // background-color: rgba(255, 255, 255, 20);
  396. // // opacity: .4;
  397. // text-align: center;
  398. // margin: 0 auto 20rpx;
  399. // }
  400. // &-btn {
  401. // .pay {
  402. // width: 400rpx;
  403. // height: 80rpx;
  404. // font-size: 36rpx;
  405. // line-height: 80rpx;
  406. // border-radius: 20rpx;
  407. // background-color: rgba(235, 112, 9, 100);
  408. // color: #FFFFFF;
  409. // text-align: center;
  410. // }
  411. // }
  412. // .index {
  413. // margin: 60rpx 0;
  414. // text-align: center;
  415. // font-weight: bold;
  416. // color: $uni-color-primary;
  417. // }
  418. }
  419. .null-prize {
  420. display: flex;
  421. flex-direction: column;
  422. align-items: center;
  423. justify-content: center;
  424. width: 80vw;
  425. height: 320rpx;
  426. background-color: #FFFFFF;
  427. border: 1px solid rgba(187, 187, 187, 100);
  428. .btn {
  429. margin-top: 60rpx;
  430. width: 160rpx;
  431. height: 60rpx;
  432. line-height: 60rpx;
  433. border-radius: 8rpx;
  434. background-color: rgba(235, 112, 9, 100);
  435. color: rgba(255, 255, 255, 100);
  436. font-size: 28rpx;
  437. text-align: center;
  438. }
  439. }
  440. </style>