index.vue 7.5 KB

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