action.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <view class="content">
  3. <image :src="actionImg" mode="widthFix" class="action-img"></image>
  4. <view class="notice-item">
  5. <view class="" v-html="content">
  6. </view>
  7. </view>
  8. <view class="action-wrap">
  9. <image src="../../static/image/action-top.png" mode="" class="action-top"></image>
  10. <view class="">
  11. 请拍下您与爱车的合照,点击下方按钮上传照片即可获得奖励。
  12. </view>
  13. <image :src="upimg" mode="widthFix" class="up-img" v-if="upimg" @click="upActionImg"></image>
  14. <image src="../../static/image/upimg-g.png" mode="widthFix" class="up-img" v-else @click="upActionImg"></image>
  15. <view class="action-btn" @click="joinAction">
  16. 上传照片
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. import { upload } from '@/api/order.js'
  23. import { details,joinAction } from '@/api/index.js'
  24. export default {
  25. data() {
  26. return {
  27. content: '',
  28. upimg: '',
  29. loading:false,
  30. id: ''
  31. };
  32. },
  33. computed: {
  34. actionImg() {
  35. return this.$store.state.baseURL + '/static/img/action.png'
  36. }
  37. },
  38. onLoad(opt) {
  39. if(opt.id ) {
  40. this.id = opt.id
  41. this.details(opt.id)
  42. }
  43. },
  44. onShow() {
  45. },
  46. onReachBottom() {
  47. },
  48. methods: {
  49. details(id) {
  50. details({},id).then(res => {
  51. console.log(res);
  52. this.content = res.data.content
  53. if(this.content != null){
  54. this.content = this.content.replace(/<img/g,"<img style='max-width:100%;height:auto;'");
  55. }//小程序商品详情图超出屏幕问题
  56. })
  57. },
  58. upActionImg() {
  59. upload().then(res => {
  60. this.upimg = res[0].url
  61. })
  62. },
  63. joinAction() {
  64. if(this.loading) {
  65. return
  66. }
  67. if(this.upimg == '') {
  68. return this.$api.msg('请上传合影照片')
  69. }
  70. this.loading = true
  71. joinAction({
  72. aid: this.id,
  73. up_file: this.upimg
  74. }).then(res => {
  75. this.loading = false
  76. uni.showToast({
  77. title: '提交成功',
  78. duration: 2000
  79. });
  80. }).catch(err => {
  81. this.loading = false
  82. })
  83. }
  84. }
  85. };
  86. </script>
  87. <style lang="scss" scoped>
  88. .content {
  89. padding-bottom: 50px;
  90. }
  91. page {
  92. background-color: #fff;
  93. height: auto;
  94. min-height: 100%;
  95. }
  96. .action-img {
  97. width: 750rpx;
  98. }
  99. .action-wrap {
  100. width: 690rpx;
  101. margin:50rpx auto 20rpx;
  102. // height: 560rpx;
  103. background-color: #dcf4ef;
  104. border-radius: 20rpx;
  105. padding: 60px 35rpx;
  106. display: flex;
  107. flex-direction: column;
  108. justify-content: space-between;
  109. align-items: center;
  110. text-align: justify;
  111. color: #333;
  112. font-weight: bold;
  113. font-size: 28rpx;
  114. position: relative;
  115. .up-img {
  116. width: 160rpx;
  117. height: 160rpx;
  118. margin: 45rpx auto;
  119. }
  120. .action-btn {
  121. width: 580rpx;
  122. height: 90rpx;
  123. color: #fff;
  124. font-weight: 500;
  125. background-color: #ffc43d;
  126. text-align: center;
  127. border-radius: 45rpx;
  128. line-height: 90rpx;
  129. }
  130. .action-top {
  131. width: 345rpx;
  132. height: 60rpx;
  133. position: absolute;
  134. top: -30rpx;
  135. left: 0;
  136. right: 0;
  137. margin: auto;
  138. }
  139. }
  140. .notice-item {
  141. width: 100%;
  142. height: 100%;
  143. padding: 35rpx 35rpx;
  144. padding-bottom: 30rpx;
  145. }
  146. </style>