buyPromo.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <view class=" ">
  3. <view class="font header">
  4. 优惠码价格:{{price}}元/个
  5. </view>
  6. <view class="font header">
  7. <view class="font">
  8. 你要购买的数量:
  9. </view>
  10. <view class="input-two">
  11. <input type="text" class="input" v-model="num" />
  12. </view>
  13. <view class="font3">
  14. </view>
  15. </view>
  16. <view class="font2 header">
  17. <view class="font">
  18. 有效期:
  19. </view>
  20. <view class="input-two">
  21. <input type="text" class="input" v-model="day" />
  22. </view>
  23. <view class="font3">
  24. 天.(最长90天)
  25. </view>
  26. </view>
  27. <view class="font2 header">
  28. 合计:{{num*price}}元
  29. </view>
  30. <view class="button">
  31. <button type="primary" @click="buy()" class="button2">
  32. <p class="p">购买</p>
  33. </button>
  34. </view>
  35. <view class="" style="margin: auto;">
  36. <font class="font1">{{title}}</font>
  37. <image class="img" :src=img mode=""></image>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. export default {
  43. data() {
  44. return {
  45. price:null,
  46. num:'10',
  47. day:'30',
  48. title:'',
  49. img:null
  50. }
  51. },
  52. onLoad() {
  53. },
  54. onShow() {
  55. this.findPrice();
  56. },
  57. methods: {
  58. findPrice(){
  59. var token = uni.getStorageSync("token");
  60. uni.request({
  61. url: this.serverurl + '/TPromoCode/findPrice',
  62. method: "GET",
  63. header:{
  64. 'token':token
  65. },
  66. success: (res) => {
  67. this.price = res.data.data;
  68. }
  69. })
  70. },
  71. buy(){
  72. if(this.day>90){
  73. uni.showModal({
  74. content: '有效期不能超过90天',
  75. showCancel: false
  76. });
  77. return null;
  78. }
  79. var p = this.price;
  80. var n = this.num;
  81. var pri = p*n;
  82. if(pri==0){
  83. uni.showModal({
  84. content: '价格为0',
  85. showCancel: false
  86. });
  87. return null;
  88. }
  89. var globalUser = uni.getStorageSync("globalUser");
  90. var id = globalUser.id;
  91. uni.request({
  92. url: this.serverurl + '/TPromoCode/buy?pri='+pri+'&adminId='+id+'&day='+this.day,
  93. method: "GET",
  94. success: (res) => {
  95. var img = res.data.data;
  96. this.title = "请用微信扫码支付";
  97. this.img = img;
  98. }
  99. })
  100. }
  101. },
  102. }
  103. </script>
  104. <style>
  105. .header {
  106. display: flex;
  107. flex-direction: row;
  108. justify-content: flex-start;
  109. padding-left: 20upx;
  110. }
  111. .font{
  112. padding-top: 20upx;
  113. height: 70upx;
  114. color: #363D44;
  115. font-size: 36upx;
  116. font-family: "PingFang-SC-Bold";
  117. }
  118. .font2{
  119. padding-top: 40upx;
  120. padding-bottom: 30upx;
  121. height: 70upx;
  122. color: #363D44;
  123. font-size: 36upx;
  124. font-family: "PingFang-SC-Bold";
  125. }
  126. .font3{
  127. padding-left: 30upx;
  128. padding-top: 23upx;
  129. height: 70upx;
  130. color: #363D44;
  131. font-size: 36upx;
  132. font-family: "PingFang-SC-Bold";
  133. }
  134. .input-two {
  135. width: 80upx;
  136. height: 30upx;
  137. padding-top: 23upx;
  138. padding-left: 30upx;
  139. }
  140. .input {
  141. padding-left: 20upx;
  142. background-color: #FFFFFF;
  143. width: 80upx;
  144. height: 30upx;
  145. box-shadow: 0upx 0upx 20upx #D3D3D3;
  146. border-radius: 5upx;
  147. }
  148. .button{
  149. padding-top: 70upx;
  150. margin: auto;
  151. width: 80%;
  152. height: 100upx;
  153. }
  154. .button2{
  155. margin: auto;
  156. width: 80%;
  157. height: 100upx;
  158. }
  159. .p{
  160. padding-top: 2upx;
  161. margin: 0 auto;
  162. font-size: 45upx;
  163. font-family: "PingFang-SC-Bold";
  164. }
  165. .font1{
  166. color: #F4AE1B;
  167. padding-left: 300upx;
  168. padding-top: 100upx;
  169. font-size: 25upx;
  170. font-family: "PingFang-SC-Bold";
  171. }
  172. .img{
  173. height: 650upx;
  174. weight:650upx;
  175. margin: auto;
  176. }
  177. </style>