design.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <view>
  3. <tabs ref="tabs" typename="renderingstype" @getList="getList" />
  4. <float-but @onClick="toUpload" />
  5. <My_listbox ref="List" @getlist="getList" :bottomHeight="70">
  6. <design-list ref="designList" :list="list" @toDetail="toDetail" />
  7. </My_listbox>
  8. </view>
  9. </template>
  10. <script>
  11. import tabs from "./tabs.vue";
  12. import designList from "../../../../components/designList.vue";
  13. export default {
  14. components: { tabs, designList },
  15. props: {
  16. pageType: {
  17. type: String,
  18. default: "设计",
  19. },
  20. },
  21. name: "design",
  22. data() {
  23. return {
  24. content: {
  25. where: {
  26. condition: "",
  27. style: "",
  28. space: "",
  29. spec: "",
  30. },
  31. },
  32. list: [],
  33. isInitialize: false,
  34. };
  35. },
  36. methods: {
  37. init() {
  38. if (this.isInitialize) return;
  39. this.setTypes();
  40. this.getList();
  41. },
  42. setTypes() {
  43. let types = [
  44. {
  45. value: "1",
  46. remarks: "全国精选",
  47. },
  48. ];
  49. //经销商和经销商员工
  50. if ([21, 22].includes(uni.getStorageSync("userMsg").usertype)) {
  51. types.push({
  52. value: "2",
  53. remarks: "门店" + this.pageType,
  54. });
  55. } else if (99 == uni.getStorageSync("userMsg").usertype) {
  56. //消费者
  57. } else {
  58. //其他
  59. types.push({
  60. value: "2",
  61. remarks: "门店" + this.pageType,
  62. });
  63. types.push({
  64. value: "3",
  65. remarks: "全国" + this.pageType,
  66. });
  67. }
  68. this.$refs.tabs.tabs = types;
  69. this.$refs.tabs.active = types[0].value;
  70. this.$refs.tabs.setWidths();
  71. },
  72. getList(init = false) {
  73. return new Promise((resolve, reject) => {
  74. if (this.paging(this.content, init)) return;
  75. let content = this.content;
  76. let ref = this.$refs.tabs;
  77. if (ref.active == null) this.setTypes();
  78. content.querytype = ref.active;
  79. content.where = {
  80. ...content.where,
  81. ...ref.where,
  82. type: this.pageType == "设计" ? "4" : "5",
  83. };
  84. this.$Http
  85. .basic({
  86. id: 20240417144702,
  87. content: this.content,
  88. })
  89. .then((res) => {
  90. resolve();
  91. this.$refs.List.RefreshToComplete();
  92. this.$refs.List.setHeight();
  93. console.log(`获取${this.pageType}列表`, res);
  94. if (this.cutoff(res.msg)) return;
  95. this.isInitialize = true;
  96. this.$refs.designList.handleList(res.data);
  97. this.list =
  98. res.pageNumber == 1 ? res.data : this.list.concat(res.data);
  99. this.content = this.$refs.List.paging(this.content, res);
  100. });
  101. });
  102. },
  103. updateList(data = null) {
  104. if (this.content.pageNumber && this.content.pageNumber >= 2) {
  105. let that = this;
  106. let content = this.paging(this.content, true, true);
  107. this.$Http
  108. .basic({
  109. id: "20240417144702",
  110. content,
  111. })
  112. .then((res) => {
  113. console.log("更新列表", res);
  114. if (this.cutoff(res.msg)) return;
  115. res.data = res.data.map((v) => {
  116. v.cover = v.attinfos.length
  117. ? this.getSpecifiedImage(
  118. v.attinfos.find((s) => s.usetype == "sat_sharematerial") ||
  119. v.attinfos[0]
  120. )
  121. : uni.getStorageSync("site").logo || "";
  122. return v;
  123. });
  124. this.list = res.data;
  125. this.$refs.List.paging(content, res, true);
  126. if (data) handle();
  127. });
  128. function handle() {
  129. uni.showModal({
  130. title: "提示",
  131. content: "新建成功,是否立即查看",
  132. cancelText: "返回列表",
  133. confirmText: "查看详情",
  134. success: ({ confirm }) => {
  135. if (confirm) {
  136. let index = that.list.findIndex(
  137. (v) => v.sat_sharematerialid == data.sat_sharematerialid
  138. );
  139. if (index == -1) {
  140. uni.redirectTo({
  141. url: `/packageA/fullView/detail?id=${data.sat_sharematerialid}`,
  142. });
  143. that.$Http.setCount = null;
  144. } else {
  145. that.toDetail(index, 2);
  146. }
  147. } else {
  148. uni.navigateBack();
  149. }
  150. },
  151. });
  152. }
  153. }
  154. },
  155. toDetail(index, type = 1) {
  156. let item = this.list[index];
  157. if (type == 1) {
  158. uni.navigateTo({
  159. url: `/packageA/fullView/detail?id=${item.sat_sharematerialid}`,
  160. });
  161. } else {
  162. uni.redirectTo({
  163. url: `/packageA/fullView/detail?id=${item.sat_sharematerialid}`,
  164. });
  165. }
  166. this.$Http.setCount = function (detail) {
  167. item.collectcount = detail.collectcount;
  168. item.commentcount = detail.commentcount;
  169. item.likecount = detail.likecount;
  170. item.islike = detail.islike;
  171. item.iscollect = detail.iscollect;
  172. this.$set(this.list, index, item);
  173. }.bind(this);
  174. },
  175. toUpload() {
  176. uni.navigateTo({
  177. url: "/packageA/fullView/upload?pageType=" + this.pageType,
  178. });
  179. this.$Http.updateList = this.updateList.bind(this);
  180. },
  181. },
  182. };
  183. </script>
  184. <style lang="scss" scoped>
  185. page,
  186. body {
  187. height: 100vh;
  188. overflow: hidden;
  189. }
  190. </style>