buyPromo.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. var token = uni.getStorageSync("token");
  92. uni.request({
  93. url: this.serverurl + '/TPromoCode/buy?pri='+pri+'&adminId='+id+'&day='+this.day,
  94. method: "GET",
  95. header:{
  96. 'token':token
  97. },
  98. success: (res) => {
  99. var img = res.data.data;
  100. this.title = "请用微信扫码支付";
  101. this.img = img;
  102. }
  103. })
  104. }
  105. },
  106. }
  107. </script>
  108. <style>
  109. .header {
  110. display: flex;
  111. flex-direction: row;
  112. justify-content: flex-start;
  113. padding-left: 20upx;
  114. }
  115. .font{
  116. padding-top: 20upx;
  117. height: 70upx;
  118. color: #363D44;
  119. font-size: 36upx;
  120. font-family: "PingFang-SC-Bold";
  121. }
  122. .font2{
  123. padding-top: 40upx;
  124. padding-bottom: 30upx;
  125. height: 70upx;
  126. color: #363D44;
  127. font-size: 36upx;
  128. font-family: "PingFang-SC-Bold";
  129. }
  130. .font3{
  131. padding-left: 30upx;
  132. padding-top: 23upx;
  133. height: 70upx;
  134. color: #363D44;
  135. font-size: 36upx;
  136. font-family: "PingFang-SC-Bold";
  137. }
  138. .input-two {
  139. width: 80upx;
  140. height: 30upx;
  141. padding-top: 23upx;
  142. padding-left: 30upx;
  143. }
  144. .input {
  145. padding-left: 20upx;
  146. background-color: #FFFFFF;
  147. width: 80upx;
  148. height: 30upx;
  149. box-shadow: 0upx 0upx 20upx #D3D3D3;
  150. border-radius: 5upx;
  151. }
  152. .button{
  153. padding-top: 70upx;
  154. margin: auto;
  155. width: 80%;
  156. height: 100upx;
  157. }
  158. .button2{
  159. margin: auto;
  160. width: 80%;
  161. height: 100upx;
  162. }
  163. .p{
  164. padding-top: 2upx;
  165. margin: 0 auto;
  166. font-size: 45upx;
  167. font-family: "PingFang-SC-Bold";
  168. }
  169. .font1{
  170. color: #F4AE1B;
  171. padding-left: 300upx;
  172. padding-top: 100upx;
  173. font-size: 25upx;
  174. font-family: "PingFang-SC-Bold";
  175. }
  176. .img{
  177. height: 650upx;
  178. weight:650upx;
  179. margin: auto;
  180. }
  181. </style>
  182. -->