多租户商城-商户小程序端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

332 lines
7.2 KiB

2 years ago
2 years ago
2 years ago
  1. <template>
  2. <view
  3. class="qaBox"
  4. v-if="ifShow"
  5. >
  6. <view class="qaTopInfo">
  7. <view
  8. class="qaTopInfoBox"
  9. @click="goGoodsDetails"
  10. >
  11. <image :src="detailList.image"></image>
  12. <view class="qaInfoText">
  13. <h3>{{ detailList.productName }}</h3>
  14. <span>{{ detailList.count }}个问题</span>
  15. </view>
  16. </view>
  17. <view class="qaTitBox">
  18. <view class="qaTit"><i></i>
  19. <h3>{{ detailList.problem }}</h3></view>
  20. <view class="qaTitTime"><img :src="detailList.headImage" />
  21. <span class="qaName">{{ detailList.name }}</span>
  22. <span class="qaTimeInfo">{{ detailList.createTime }}</span></view>
  23. </view>
  24. </view>
  25. <view class="answerListBox">
  26. <view class="answerNum">{{ answerslength }}条回答</view>
  27. <view
  28. class="answerList"
  29. v-for="item in detailList.answers"
  30. :key="item.answerId"
  31. >
  32. <view class="answerItem">
  33. <view class="itemTit">
  34. <view class="itemAvatarBox">
  35. <img
  36. :src="item.headImage"
  37. alt=""
  38. >
  39. <span class="answerName">{{ item.name }}</span>
  40. </view>
  41. <view class="answerTime">{{ item.createTime }}</view>
  42. </view>
  43. <view class="answerInfo">{{ item.answer }}</view>
  44. </view>
  45. </view>
  46. </view>
  47. <view
  48. v-if="detailList.ifExhibition==1"
  49. class="pad-bot-100"
  50. ></view>
  51. <view
  52. class="answerBtn"
  53. v-if="detailList.ifExhibition==1"
  54. :style="{'padding-bottom':(isIphone==true? 50:0)+'rpx'}"
  55. >
  56. <view class="uni-form-item uni-column answerBtnBox">
  57. <input
  58. class="uni-input"
  59. v-model="answerText"
  60. maxlength="200"
  61. focus
  62. placeholder="被邀请的用户才能回答"
  63. />
  64. <view
  65. class="answerButton"
  66. @click="answer"
  67. >回答
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. </template>
  73. <script>
  74. const NET = require('../../utils/request')
  75. const API = require('../../config/api')
  76. import QuestionsAndAnswersList from "./components/QuestionsAndAnswersList";
  77. export default {
  78. name: "qADetail",
  79. components:{QuestionsAndAnswersList},
  80. data() {
  81. return {
  82. detailList: {},//商品问答详情
  83. productId: '',
  84. images: '',
  85. productName: '',
  86. problemsData: {},
  87. answerText: "",
  88. answerslength: 0,
  89. num: 0,
  90. isIphone: false,
  91. ifShow: false
  92. }
  93. },
  94. onLoad(options) {
  95. this.isIphone = getApp().globalData.isIphone;
  96. this.problemsData = this.$getJumpParam(options)
  97. this.getProblems()
  98. },
  99. methods: {
  100. goGoodsDetails() {
  101. let shopId = this.detailList.shopId
  102. let productId = this.detailList.productId
  103. let skuId = this.detailList.skuId
  104. uni.navigateTo({
  105. url: 'goodsDetails?shopId=' + shopId + '&productId=' + productId + '&skuId=' + skuId
  106. })
  107. },
  108. //商品问答数据
  109. getProblems() {
  110. NET.request(API.getProblemDetail, {
  111. problemId: this.problemsData.problemId,
  112. productId: this.problemsData.productId,
  113. }, 'GET').then(res => {
  114. this.detailList = res.data
  115. this.ifShow = true
  116. this.answerslength = this.detailList.answers.length
  117. uni.removeStorageSync('seeAllFnData')
  118. }).catch(res => {
  119. uni.showToast({
  120. title: '失败',
  121. icon: "none"
  122. })
  123. })
  124. },
  125. //回答
  126. answer() {
  127. NET.request(API.addAnswer, {
  128. productId: this.problemsData.productId,
  129. answer: this.answerText,
  130. problemId: this.problemsData.problemId
  131. }, 'POST').then(res => {
  132. this.getProblems()
  133. this.answerText = ""
  134. uni.showToast({
  135. title: '回答成功',
  136. icon: "success"
  137. })
  138. }).catch(res => {
  139. uni.showToast({
  140. title: '失败',
  141. icon: "none"
  142. })
  143. })
  144. }
  145. }
  146. }
  147. </script>
  148. <style
  149. lang="scss"
  150. scoped
  151. >
  152. .qaBox {
  153. padding: 0 30upx;
  154. .qaTopInfo {
  155. margin-top: 20upx;
  156. .qaTopInfoBox {
  157. border-radius: 10upx;
  158. display: flex;
  159. align-items: center;
  160. padding: 15upx 20upx;
  161. margin-bottom: 55upx;
  162. image {
  163. border: 2px solid #E4E5E6;
  164. width: 120upx;
  165. height: 120upx;
  166. margin-right: 20upx;
  167. }
  168. .qaInfoText {
  169. h3 {
  170. font-size: 30upx;
  171. font-weight: 500;
  172. color: #333333;
  173. margin-bottom: 20rpx;
  174. }
  175. span {
  176. font-size: 24upx;
  177. color: #999999;
  178. }
  179. }
  180. }
  181. .qaTitBox {
  182. padding-bottom: 30upx;
  183. border-bottom: 1upx solid #EEEEEE;
  184. .qaTit {
  185. display: flex;
  186. align-items: center;
  187. margin-bottom: 35upx;
  188. i {
  189. width: 38upx;
  190. height: 38upx;
  191. background: #C83732;
  192. font-style: normal;
  193. text-align: center;
  194. color: #FFFFFF;
  195. font-size: 20upx;
  196. margin-right: 30upx;
  197. }
  198. h3 {
  199. font-size: 28upx;
  200. font-weight: 500;
  201. color: #333333;
  202. }
  203. }
  204. .qaTitTime {
  205. display: flex;
  206. align-items: center;
  207. img {
  208. width: 44upx;
  209. height: 44upx;
  210. margin-right: 20upx;
  211. }
  212. .qaName {
  213. font-size: 28upx;
  214. color: #666666;
  215. margin-right: 35upx;
  216. }
  217. .qaTimeInfo {
  218. color: #CCCCCC;
  219. font-size: 22upx;
  220. }
  221. }
  222. }
  223. }
  224. .answerListBox {
  225. .answerNum {
  226. font-size: 24upx;
  227. color: #CCCCCC;
  228. margin-bottom: 40upx;
  229. margin-top: 30upx;
  230. }
  231. .answerList {
  232. padding-bottom: 50upx;
  233. .answerItem {
  234. margin-bottom: 10upx;
  235. .itemTit {
  236. display: flex;
  237. align-items: center;
  238. justify-content: space-between;
  239. .itemAvatarBox {
  240. display: flex;
  241. img {
  242. width: 46upx;
  243. height: 46upx;
  244. margin-right: 20upx;
  245. }
  246. .answerName {
  247. font-size: 26upx;
  248. color: #333333;
  249. font-weight: bold;
  250. }
  251. }
  252. .answerTime {
  253. color: #CCCCCC;
  254. font-size: 20upx;
  255. }
  256. }
  257. .answerInfo {
  258. color: #333333;
  259. font-size: 28upx;
  260. margin-top: 20upx;
  261. font-weight: 400;
  262. }
  263. }
  264. }
  265. }
  266. .answerBtn {
  267. position: fixed;
  268. width: 100%;
  269. bottom: 0;
  270. left: 0;
  271. .answerBtnBox {
  272. display: flex;
  273. align-items: center;
  274. justify-content: space-between;
  275. width: 100%;
  276. padding: 30upx;
  277. background: #FFFFFF;
  278. input {
  279. margin-right: 30upx;
  280. width: 530upx;
  281. background: #F1F1F1;
  282. min-height: 84upx;
  283. padding-left: 30upx;
  284. font-size: 28upx;
  285. color: #999999;
  286. }
  287. .input-placeholder {
  288. font-size: 24upx;
  289. color: #999999;
  290. }
  291. .answerButton {
  292. width: 152upx;
  293. height: 84upx;
  294. background: #333333;
  295. text-align: center;
  296. line-height: 84upx;
  297. font-size: 30upx;
  298. color: #FFEBC4;
  299. }
  300. }
  301. }
  302. }
  303. </style>