check.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <template>
  2. <view class="page">
  3. <view class="form">
  4. <u-form :model="form" ref="uForm">
  5. <u-form-item label-width="150" label="报备客户" prop="curName">
  6. <u-input placeholder="请输入推荐人" v-model="curName" disabled="true" type="text"></u-input>
  7. </u-form-item>
  8. <u-form-item label-width="150" label="报备状态" prop="report_state" required>
  9. <u-radio-group v-model="form.report_state" active-color="#2979ff">
  10. <u-radio name="1">有效</u-radio>
  11. <u-radio name="3">无效</u-radio>
  12. </u-radio-group>
  13. </u-form-item>
  14. <u-form-item label-position="top" label-width="150" label="报备二维码(非江投必填)" prop="report_code">
  15. <view class="id_card" @click="uploadImage">
  16. <u-icon v-if="form.report_code == null" name="plus" size="32" color="#606266"></u-icon>
  17. <text v-if="form.report_code == null">请先上传报备二维码照片</text>
  18. <image v-if="form.report_code != null" :src="form.report_code" mode="aspectFill"></image>
  19. </view>
  20. </u-form-item>
  21. <u-form-item label-width="150" label="备注信息" prop="remark" label-position="top">
  22. <u-input placeholder="备注信息,将显示在报备的详情页面" v-model="form.remark" type="textarea"></u-input>
  23. </u-form-item>
  24. </u-form>
  25. <u-gap height="60"></u-gap>
  26. <u-button type="primary" @click="submitHandle">确定</u-button>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. var that;
  32. export default {
  33. data() {
  34. return {
  35. eId: '',
  36. curName: '',
  37. curId: '',
  38. form: {
  39. report_code: null,
  40. report_state: '1',
  41. },
  42. };
  43. },
  44. onLoad(params) {
  45. this.curId = params.id
  46. this.eId = params.eid
  47. this.curName = params.name
  48. },
  49. // 必须要在onReady生命周期,因为onLoad生命周期组件可能尚未创建完毕
  50. onReady() {
  51. this.$refs.uForm.setRules(this.rules);
  52. },
  53. methods: {
  54. getTime(n) {
  55. let date = n ? new Date(n) : new Date()
  56. let year = date.getFullYear()
  57. let month = date.getMonth() + 1
  58. month = month > 9 ? month : '0' + month
  59. let day = date.getDate()
  60. day = day > 9 ? day : '0' + day
  61. let hour = date.getHours()
  62. hour = hour > 9 ? hour : '0' + hour
  63. let minute = date.getMinutes()
  64. minute = minute > 9 ? minute : '0' + minute
  65. let second = date.getSeconds()
  66. second = second > 9 ? second : '0' + second
  67. return `${year}-${month}-${day} ${hour}:${minute}:${second}`
  68. },
  69. uploadImgHandle (bc) {
  70. uni.chooseImage({
  71. count: 1,
  72. sizeType: ['compressed'],
  73. success: function(res) {
  74. const filePath = res.tempFilePaths[0];
  75. let token = uni.getStorageSync('MD_token') || ''
  76. uni.uploadFile({
  77. url: uni.baseUrl + 'api/upload/cloud',
  78. filePath,
  79. name: 'upload',
  80. formData: {
  81. 'token': token
  82. },
  83. success: (f) => {
  84. const cData = JSON.parse(f.data)
  85. if (cData.errno === 0) {
  86. if (bc && typeof(bc) === 'function') bc(cData.data)
  87. } else {
  88. uni.$msg(cData.errmsg || `未知错误-${cData.errno}`)
  89. }
  90. }
  91. })
  92. }
  93. })
  94. },
  95. // 上传照片
  96. uploadImage() {
  97. this.uploadImgHandle((d) => {
  98. this.form.report_code = d.url
  99. })
  100. },
  101. submitHandle() {
  102. if (this.eId != 2) {
  103. if (!this.form.report_code) {
  104. uni.$msg('非江投项目,请上传报备二维码~')
  105. return
  106. }
  107. }
  108. const that = this
  109. this.$refs.uForm.validate(valid => {
  110. if (valid) {
  111. let params = {
  112. ...that.form,
  113. id: that.curId,
  114. report_at: that.getTime()
  115. }
  116. uni.api.cust.apireportverify(params).then(res => {
  117. uni.$msgConfirm('编辑成功', () => {
  118. uni.reLaunch({
  119. url: '/pages/agent/recommend/list'
  120. })
  121. }, () => {
  122. uni.reLaunch({
  123. url: '/pages/agent/recommend/list'
  124. })
  125. })
  126. })
  127. }
  128. });
  129. },
  130. // 以下是工具函数
  131. // 格式化日期的月份或天数的显示(小于10,在前面增加0)
  132. getFormatDate(value) {
  133. if (value == undefined || value == '') {
  134. return '';
  135. }
  136. var str = value;
  137. if (parseInt(value) < 10) {
  138. str = '0' + value;
  139. }
  140. return str;
  141. }
  142. }
  143. };
  144. </script>
  145. <style lang="scss">
  146. .page {
  147. background-color: #ffffff;
  148. }
  149. .form {
  150. border-radius: 10rpx;
  151. padding: 0 40rpx;
  152. }
  153. .popup-body {
  154. .tips-title {
  155. font-size: $u-p;
  156. margin-bottom: 20rpx;
  157. }
  158. .tips-content {
  159. font-size: $u-p2;
  160. color: $u-tips-color;
  161. margin-bottom: 60rpx;
  162. }
  163. }
  164. .id_card {
  165. color: #606266;
  166. width: 100%;
  167. height: 350rpx;
  168. display: flex;
  169. flex-direction: column;
  170. align-items: center;
  171. justify-content: center;
  172. background-color: #f4f5f6;
  173. font-size: $u-p2;
  174. border-radius: 10rpx;
  175. image {
  176. border-radius: 10rpx;
  177. }
  178. }
  179. .footer {
  180. position: relative;
  181. text-align: center;
  182. font-size: $u-p2;
  183. left: 0;
  184. bottom: 20rpx;
  185. .agreement {
  186. color: $u-theme-color;
  187. }
  188. }
  189. .slot-content {
  190. font-size: 28rpx;
  191. color: $u-content-color;
  192. padding: 20rpx;
  193. }
  194. .warp {
  195. display: flex;
  196. flex-direction: column;
  197. align-items: center;
  198. justify-content: center;
  199. height: 100%;
  200. }
  201. .rect {
  202. width: 400rpx;
  203. height: 400rpx;
  204. background-color: #fff;
  205. }
  206. </style>