code.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <view class="app-content">
  3. <view class="img_box" style="margin-top:30upx;">
  4. <image :src="gatherUrl" mode="heightFix" class="img_url"></image>
  5. </view>
  6. <view style="font-size:30upx;text-align: center;margin:30upx 0 5upx 0;">支持信用卡和花呗,打印尺寸100mmx150mm</view>
  7. <view class="confirm-btn">
  8. <button class="admin-button-com big blue" style="width:60vw;" @click="downloadImg(gatherUrl)">下载收款码</button>
  9. </view>
  10. <view class="confirm-btn">
  11. <button class="admin-button-com big blue" style="width:60vw;" @click="startRenew(2,160)">购买音响 ¥160</button>
  12. </view>
  13. <view style="margin-top:30upx;text-align:center;margin-bottom:30upx;">
  14. <image :src="laba" mode="widthFix" style="width:640upx;margin:0 auto;border-radius: 10upx;"></image>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. import { miniGatheringCode } from '@/api/shop'
  20. import wexinPay from "@/utils/pay/wxPay"
  21. import { renewShop,needRemind } from "@/api/renew"
  22. export default {
  23. data() {
  24. return {
  25. gatherUrl:'',
  26. laba: `${this.$constant.hostUrl}/image/horn.jpg`,
  27. }
  28. },
  29. methods: {
  30. init() {
  31. this.getImg()
  32. },
  33. startRenew(type,price){
  34. let that = this
  35. // #ifdef APP-PLUS
  36. that.$msg("APP不能操作,请打开微信小程序操作")
  37. // #endif
  38. // #ifdef MP-WEIXIN
  39. uni.showLoading({mask:true})
  40. if(type == 1){
  41. if(Number(price) <= 0){
  42. that.$msg("请输入金额")
  43. return false
  44. }
  45. }
  46. this.renewType = type
  47. renewShop({price:price,type:type,remark:this.remark}).then(res=>{
  48. uni.hideLoading()
  49. if(res.code == 1){
  50. wexinPay(res.data, this.getSuccess, this.getError)
  51. }
  52. })
  53. // #endif
  54. },
  55. getSuccess(){
  56. this.$util.pageTo({url:"/admin/shop/renewSuccess?type="+this.renewType,type:2})
  57. },
  58. getError(){
  59. },
  60. closeRenew(){
  61. uni.navigateBack()
  62. },
  63. downloadImg(url){
  64. // #ifdef APP-PLUS
  65. let platformType = uni.getSystemInfoSync().platform
  66. if(platformType == 'android'){
  67. let store = plus.navigator.checkPermission('android.permission.READ_EXTERNAL_STORAGE')
  68. if(store != 'authorized'){
  69. this.$util.confirmModal({content:'将申请您的存储权限,用于保存小程序码'},() => {
  70. this.downloadImg2(url)
  71. })
  72. }else{
  73. this.downloadImg2(url)
  74. }
  75. }else{
  76. this.downloadImg2(url)
  77. }
  78. // #endif
  79. // #ifdef MP-WEIXIN
  80. this.downloadImg2(url)
  81. // #endif
  82. },
  83. downloadImg2(url){
  84. uni.downloadFile({
  85. url: url,
  86. success: (res) => {
  87. if (res.statusCode === 200) {
  88. uni.saveImageToPhotosAlbum({
  89. filePath: res.tempFilePath,
  90. success: function (data) {
  91. uni.showToast({title:'下载成功!'})
  92. }
  93. });
  94. }
  95. }
  96. });
  97. },
  98. getImg() {
  99. miniGatheringCode().then(res => {
  100. this.gatherUrl = res.data.imgUrl
  101. })
  102. }
  103. }
  104. }
  105. </script>
  106. <style lang="scss" scoped>
  107. .app-content{
  108. overflow: hidden;
  109. }
  110. .img_box{
  111. height:900upx;
  112. box-sizing: border-box;
  113. &>.img_url{
  114. height:900upx;
  115. width: auto;
  116. margin: 20upx auto;
  117. }
  118. }
  119. // 按钮
  120. .confirm-btn {
  121. width: calc(100% - 60upx);
  122. margin: 30upx 30upx 20upx;
  123. text-align:center;
  124. .admin-button-com {
  125. width: 100%;
  126. }
  127. }
  128. // 按钮
  129. .confirm-btn1 {
  130. width: calc(100% - 60upx);
  131. margin: 30upx 30upx 20upx;
  132. text-align:center;
  133. .admin-button-com {
  134. width: 100%;
  135. }
  136. }
  137. </style>