addFriendCirlce.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <view class="content">
  3. <view class="row1">
  4. <u-input placeholder="这一刻得想法..." focus :border="false" v-model="formData.content"></u-input>
  5. </view>
  6. <view class="row2">
  7. <cl-upload v-model="fileList" @onSuccess="onSuccess" @showType='getShowType($event)'></cl-upload>
  8. </view>
  9. <view class="row3 flex flex-between" @click="selectPlace">
  10. <view class="left flex">
  11. <u-icon name="map-fill" color="#112253" size="18"></u-icon>
  12. <text style="margin:0 20rpx;">{{formData.location?formData.location:'所在位置'}}</text>
  13. </view>
  14. <view class="right">
  15. <u-icon name="arrow-right" color="#112253" size="20"></u-icon>
  16. </view>
  17. </view>
  18. <view class="row4 flex flex-between">
  19. <view class="left flex">
  20. <u-icon name="pushpin" color="#112253" size="18"></u-icon>
  21. <text style="margin:0 20rpx;">开启评论</text>
  22. <u-switch v-model="switchStatus" activeColor="#112253" @change="change($event,1)" size="20"></u-switch>
  23. </view>
  24. <view class="right">
  25. <u-icon name="arrow-right" color="#112253" size="20"></u-icon>
  26. </view>
  27. </view>
  28. <view @click="submit" class="submit">提交</view>
  29. </view>
  30. </template>
  31. <script>
  32. var that;
  33. import uploadImage from '@/components/ossutil/uploadFile.js';
  34. export default {
  35. data() {
  36. return {
  37. userInfo: {},
  38. switchStatus: true,
  39. fileList: [],
  40. formData: {
  41. commonId: '',
  42. head: '',
  43. nickname: '',
  44. content: '',
  45. image: '',
  46. location: '',
  47. commentFlag: '',
  48. positioning:'',
  49. circleId:'',
  50. mediaType:''
  51. }
  52. };
  53. },
  54. onShow() {
  55. this.userInfo = uni.getStorageSync("userInfo")
  56. },
  57. onLoad(options) {
  58. that = this
  59. this.formData.circleId = options.id
  60. },
  61. methods: {
  62. getShowType(type){
  63. console.log("文件类型",type)
  64. this.mediaType = type
  65. },
  66. onSuccess(reslut) {
  67. // 把服务端返回的图片地址添加到list中与组件数据同步
  68. this.fileList.push(reslut)
  69. },
  70. submit() {
  71. this.formData.commonId = this.userInfo.id
  72. this.formData.head = this.userInfo.head
  73. this.formData.nickname = this.userInfo.nickname
  74. this.formData.image = this.fileList.toString()
  75. this.formData.mediaType = this.mediaType
  76. if (this.switchStatus) {
  77. this.formData.commentFlag = 1
  78. } else {
  79. this.formData.commentFlag = 0
  80. }
  81. if (!this.formData.content) {
  82. uni.showToast({
  83. icon: "none",
  84. title: '内容不能为空!',
  85. duration: 2000
  86. });
  87. return
  88. }
  89. this.$request.baseRequest('admin.unimall.circleFriendsInfo', 'add', {
  90. circleFriendsInfo: JSON.stringify(this.formData)
  91. }, failres => {
  92. uni.showToast({
  93. icon: "none",
  94. title: failres.errmsg,
  95. duration: 3000
  96. });
  97. uni.hideLoading()
  98. }).then(res => {
  99. })
  100. uni.showToast({
  101. icon: "success",
  102. title: '保存成功!',
  103. duration: 2000
  104. });
  105. setTimeout(() => {
  106. uni.navigateBack()
  107. }, 2000)
  108. },
  109. selectPlace() {
  110. uni.chooseLocation({
  111. success: function(res) {
  112. that.formData.location = res.address
  113. console.log('位置名称:' + res.name);
  114. console.log('详细地址:' + res.address);
  115. console.log('纬度:' + res.latitude);
  116. console.log('经度:' + res.longitude);
  117. }
  118. });
  119. }
  120. }
  121. }
  122. </script>
  123. <style lang="scss">
  124. .content {
  125. background-color: #fff;
  126. padding: 40rpx;
  127. .row2,
  128. .row3 {
  129. border-bottom: 1px solid #E6E6E6;
  130. padding: 30rpx 0;
  131. }
  132. .row4 {
  133. padding-top: 30rpx;
  134. }
  135. }
  136. .submit {
  137. position: fixed;
  138. bottom: 100rpx;
  139. background: #112253;
  140. color: #fff;
  141. width: calc(100% - 80rpx);
  142. padding: 20rpx;
  143. box-sizing: border-box;
  144. text-align: center;
  145. border-radius: 20rpx;
  146. }
  147. </style>