index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  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-tip"><text>请刮开纸质票面的数字,与此幸运数字相同的就是所中奖项</text></view> -->
  17. <view class="flex lucky-btn">
  18. <view class="pay" @click="pay" v-if="info.status == 1">支付{{ info.salePrice / 100 }}元 立即查看</view>
  19. <view class="pay" @click="saveImg" v-else>保存至手机相册</view>
  20. </view>
  21. </view>
  22. <pay-popup :pay-show="payShow" :pay-info="payInfo" @close="close" @success="getDetailInfo" />
  23. <u-popup :show="showNull" :round="10" mode="center" :safeAreaInsetBottom="false">
  24. <view class="null-prize">
  25. <view class="title">该盲票已兑奖</view>
  26. <view class="btn" @click="toIndex">确认</view>
  27. </view>
  28. </u-popup>
  29. <hch-poster ref="hchPoster" @cancel="handleCancel" :posterData.sync="posterData" @previewImage='previewImage'
  30. @canvasConfirm="toIndex" />
  31. </view>
  32. </template>
  33. <script>
  34. import env from '../../config/env.js'
  35. import $http from '@/utils/request.js'
  36. import PayPopup from '../../components/pay-popup/pay-popup.vue'
  37. import HchPoster from "../../components/hch-poster/hch-poster.vue"
  38. export default {
  39. components: {
  40. PayPopup,
  41. HchPoster
  42. },
  43. data() {
  44. return {
  45. serialNo: '',
  46. info: '',
  47. payInfo: {},
  48. payShow: false,
  49. payLookFlag: true,
  50. showNull: false,
  51. posterData: {}
  52. };
  53. },
  54. onLoad(options) {
  55. if (options.id) {
  56. console.log(options);
  57. this.serialNo = options.id
  58. }
  59. if (options.q) {
  60. let url = JSON.stringify(options.q)
  61. this.serialNo = url.substring(url.length - 22, url.length - 1)
  62. }
  63. },
  64. onShow() {
  65. if (this.serialNo && this.payLookFlag) {
  66. this.getDetail()
  67. }
  68. },
  69. methods: {
  70. getDetail() {
  71. uni.showLoading({
  72. title: '加载中'
  73. });
  74. $http.post('/api/v1/mp/user/ticket/queryLuckyNum', {
  75. serialNo: this.serialNo,
  76. noToken: true
  77. }).then(res => {
  78. uni.hideLoading();
  79. if (res.code == 0) {
  80. if (res.data.status == 1) {
  81. this.info = res.data
  82. } else if (res.data.status == 2) {
  83. if (uni.getStorageSync('token')) {
  84. uni.redirectTo({
  85. url: `/pages/choice/index?id=${ res.data.ticketId }`
  86. })
  87. } else {
  88. uni.showModal({
  89. title: '提示',
  90. content: '您未登录或登录失效!',
  91. confirmText: '去登录',
  92. showCancel: false,
  93. success(res) {
  94. if (res.confirm) {
  95. uni.navigateTo({
  96. url: "/pages/login/index"
  97. })
  98. }
  99. }
  100. })
  101. }
  102. } else {
  103. this.showNull = true
  104. }
  105. } else {
  106. uni.$u.toast('该盲票不存在!');
  107. setTimeout(() => {
  108. uni.switchTab({
  109. url: '/pages/index/index'
  110. })
  111. }, 1000)
  112. }
  113. }).catch(() => {
  114. uni.hideLoading();
  115. })
  116. },
  117. getDetailInfo() {
  118. this.payShow = false
  119. uni.showLoading({
  120. title: '加载中'
  121. });
  122. $http.post('/api/v1/mp/user/ticket/queryLuckyNum', {
  123. serialNo: this.serialNo,
  124. noToken: true
  125. }).then(res => {
  126. uni.hideLoading();
  127. if (res.code == 0) {
  128. this.info = res.data
  129. let num = res.data.plainLuckyNum
  130. this.posterData.num.text =
  131. this.posterData = {
  132. poster: {
  133. //根据屏幕大小自动生成图片背景大小
  134. url: env.filePublic + this.info.picUrl, //图片地址
  135. r: 10, //圆角半径
  136. w: 300, //图片宽度
  137. h: 480, //图片高度
  138. p: 20 //图片内边距padding
  139. },
  140. square3: {
  141. x: 100,
  142. y: 100,
  143. r: 0, //圆角半径
  144. w: 240, //宽度
  145. h: 180, //高度
  146. mt: 65
  147. },
  148. title: {
  149. text: "幸运数字", //文本
  150. fontSize: 20, //字体大小
  151. color: "#000", //颜色
  152. lineHeight: 25, //行高
  153. mt: 20, //margin-top
  154. align: 'center'
  155. },
  156. num: {
  157. text: num + '', //文本
  158. fontSize: 40, //字体大小
  159. color: "#fff", //颜色
  160. lineHeight: 25, //行高
  161. mt: 20, //margin-top
  162. align: 'center'
  163. },
  164. txt: {
  165. text: res.data.title, //文本
  166. fontSize: 16, //字体大小
  167. color: "#000", //颜色
  168. lineHeight: 25, //行高
  169. mt: 20, //margin-top
  170. align: 'center'
  171. },
  172. }
  173. }
  174. }).catch(() => {
  175. uni.hideLoading();
  176. })
  177. },
  178. close() {
  179. this.payShow = false
  180. },
  181. pay() {
  182. let data = {
  183. ticketId: this.info.ticketId,
  184. autoCoupon: 1
  185. }
  186. this.payLookFlag = false
  187. uni.showLoading({
  188. title: '加载中'
  189. });
  190. $http.post('/api/v1/mp/user/ticket/order/settle', data).then(res => {
  191. uni.hideLoading();
  192. if (res.code == 0) {
  193. let info = {
  194. ...res.data,
  195. ...this.info,
  196. picUrl: env.filePublic + res.data.picUrl,
  197. }
  198. this.payInfo = info
  199. this.payShow = true
  200. }
  201. }).catch(() => {
  202. uni.hideLoading();
  203. })
  204. },
  205. screen() {
  206. },
  207. toIndex() {
  208. uni.switchTab({
  209. url: '/pages/index/index'
  210. })
  211. },
  212. previewImage() {
  213. },
  214. saveImg() {
  215. this.$refs.hchPoster.posterShow()
  216. },
  217. handleCancel() {
  218. },
  219. toIndex() {
  220. uni.switchTab({
  221. url: '/pages/index/index'
  222. })
  223. },
  224. }
  225. }
  226. </script>
  227. <style lang="scss" scoped>
  228. .lucky {
  229. width: 100%;
  230. min-height: calc(100vh - 44px - var(--status-bar-height));
  231. background: url(https://mp-public-1310078123.cos.ap-shanghai.myqcloud.com/background.png) center center;
  232. &-number {
  233. padding-top: 300rpx;
  234. &-circle {
  235. box-sizing: border-box;
  236. flex-direction: column;
  237. width: 336rpx;
  238. height: 336rpx;
  239. background-color: #FFFFFF;
  240. border-radius: 50%;
  241. margin: auto;
  242. .title {
  243. margin-bottom: 20rpx;
  244. }
  245. .num {
  246. font-size: 120rpx;
  247. color: #E86737;
  248. }
  249. .luckyNum {
  250. font-size: 120rpx;
  251. color: #E86737;
  252. }
  253. }
  254. }
  255. &-title {
  256. margin-top: 40rpx;
  257. margin-bottom: 200rpx;
  258. .txt {
  259. text-align: center;
  260. font-size: 36rpx;
  261. font-weight: bold;
  262. line-height: 50rpx;
  263. margin-bottom: 8rpx;
  264. }
  265. .id {
  266. line-height: 40rpx;
  267. text-align: center;
  268. color: #888787;
  269. }
  270. }
  271. &-tip {
  272. padding: 0 40rpx;
  273. color: #333;
  274. width: 80vw;
  275. height: 200rpx;
  276. ;
  277. border-radius: 10rpx;
  278. background-color: rgba(255, 255, 255, 20);
  279. // opacity: .4;
  280. text-align: center;
  281. margin: 0 auto 20rpx;
  282. }
  283. &-btn {
  284. .pay {
  285. width: 400rpx;
  286. height: 80rpx;
  287. font-size: 36rpx;
  288. line-height: 80rpx;
  289. border-radius: 20rpx;
  290. background-color: rgba(235, 112, 9, 100);
  291. color: #FFFFFF;
  292. text-align: center;
  293. }
  294. }
  295. .index {
  296. margin: 60rpx 0;
  297. text-align: center;
  298. font-weight: bold;
  299. color: $uni-color-primary;
  300. }
  301. }
  302. .null-prize {
  303. display: flex;
  304. flex-direction: column;
  305. align-items: center;
  306. justify-content: center;
  307. width: 80vw;
  308. height: 320rpx;
  309. background-color: #FFFFFF;
  310. border: 1px solid rgba(187, 187, 187, 100);
  311. .btn {
  312. margin-top: 60rpx;
  313. width: 160rpx;
  314. height: 60rpx;
  315. line-height: 60rpx;
  316. border-radius: 8rpx;
  317. background-color: rgba(235, 112, 9, 100);
  318. color: rgba(255, 255, 255, 100);
  319. font-size: 28rpx;
  320. text-align: center;
  321. }
  322. }
  323. </style>